xiaohongshu
xiaohongshu
imis-api
iMIS API integration patterns and workflows. Use when implementing iMIS API features, adding new endpoints, creating schemas, or debugging API issues. Triggers on: iMIS, ImisApiService, iMIS API, API endpoint, iMIS schema.
Full skill instructions
Do NOT rely on web searches for iMIS API information. Instead, use the reference implementation:
~/.local/share/imis/index.ts
This file contains working API call patterns for many iMIS endpoints. Search it for the endpoint you need:
grep -n "api.party\|api.query\|api.document" ~/.local/share/imis/index.ts
Important: The reference code shows correct request shapes and URL patterns, but may need refactoring to use Effect patterns. Don't copy verbatim—adapt to this project's Effect-based architecture.
When implementing a new iMIS API endpoint:
Search the reference code for similar functionality:
grep -A 20 "relevant-endpoint-name" ~/.local/share/imis/index.ts
Create a script to hit the real API and inspect the response. This is critical because iMIS response schemas are complex and often inconsistent.
Template (test/scripts/explore-{endpoint}.ts):
import { Effect } from "effect"
// Get credentials from environment
const baseUrl = process.env.IMIS_BASE_URL!
const username = process.env.IMIS_USERNAME!
const password = process.env.IMIS_PASSWORD!
// Get token
const tokenResponse = await fetch(`${baseUrl}/token`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `grant_type=password&username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`,
})
const { access_token } = await tokenResponse.json()
// Make API request
const response = await fetch(`${baseUrl}/api/{endpoint}`, {
headers: {
Authorization: `Bearer ${access_token}`,
Accept: "application/json",
},
})
const data = await response.json()
// Pretty print for schema analysis
console.log(JSON.stringify(data, null, 2))
Run with:
bun test/scripts/explore-{endpoint}.ts
Look for:
$type fields indicating .NET SOA contract types$values arrays (iMIS collection pattern){ $type: "System.XXX", $value: ... } wrapped primitivesProperties arrays with GenericPropertyDatasrc/api/imis-schemas.tsImisApiService in src/services/imis-api.tssrc/api/handlers.tsFollow existing patterns in src/api/imis-schemas.ts:
// For simple response types
export const MyResponseSchema = Schema.Struct({
$type: Schema.String,
SomeField: Schema.String,
Items: Schema.Struct({
$type: Schema.String,
$values: Schema.Array(MyItemSchema),
}),
})
// For wrapped values (common in iMIS)
export const WrappedValue = Schema.Struct({
$type: Schema.String,
$value: Schema.Unknown,
})
Use the executeWithAuth pattern:
myMethod: (envId: string, param: string) =>
executeWithAuth(envId, `/api/MyEndpoint`, (token, env) =>
HttpClientRequest.get(`${env.baseUrl}/api/MyEndpoint`)
.pipe(
HttpClientRequest.setUrlParam("param", param),
HttpClientRequest.bearerToken(token),
HttpClientRequest.setHeader("Accept", "application/json"),
httpClient.execute,
Effect.flatMap(HttpClientResponse.schemaBodyJson(MyResponseSchema)),
Effect.scoped,
Effect.withSpan("imis.myMethod", {
attributes: { environmentId: envId, param },
})
)
),
For POST requests with _execute pattern:
myExecuteMethod: (envId: string, operation: string, params: Record<string, unknown>) =>
executeWithAuth(envId, `/api/MyEndpoint/_execute`, (token, env) =>
HttpClientRequest.post(`${env.baseUrl}/api/MyEndpoint/_execute`)
.pipe(
HttpClientRequest.bearerToken(token),
HttpClientRequest.setHeader("Content-Type", "application/json"),
HttpClientRequest.jsonBody({
$type: "Asi.Soa.Core.DataContracts.GenericExecuteRequest, Asi.Contracts",
OperationName: operation,
EntityTypeName: "MyEndpoint",
Parameters: {
$type: "System.Collections.Generic.Dictionary`2[[System.String],[System.Object]], mscorlib",
...params,
},
}),
httpClient.execute,
Effect.flatMap(HttpClientResponse.schemaBodyJson(MyExecuteResponseSchema)),
Effect.scoped,
Effect.withSpan("imis.myExecuteMethod", { attributes: { environmentId: envId, operation } })
)
),
| File | Purpose |
|---|---|
src/services/imis-api.ts | ImisApiService - all API methods |
src/api/imis-schemas.ts | Request/response schemas |
src/api/handlers.ts | RPC handlers using the API |
src/api/procedures.ts | RPC procedure definitions |
test/imis-api/setup.ts | Test environment setup patterns |
~/.local/share/imis/index.ts | Reference API patterns |
limit and offset query paramsCount, TotalCount, HasNext, NextOffset/api/query, 2017 uses /api/iqanormalize2017Response)env.version to determine which endpointConvert to/from flat objects:
// To properties array (for requests)
const properties = Object.entries(data).map(([Name, Value]) => ({ Name, Value }))
// From properties array (for responses)
const flat = Object.fromEntries(props.map((p) => [p.Name, unwrapValue(p.Value)]))
ImisAuthError - Authentication failedImisRequestError - Network/connection errorImisResponseError - HTTP error (includes status code)ImisSchemaError - Response parsing failedIntegration tests use the pattern from test/imis-api/:
describe.skipIf(!shouldRunIntegrationTests())("My Feature", () => {
let envId: string
beforeAll(async () => {
envId = await createTestEnvironment()
})
afterAll(async () => {
await cleanupTestEnvironment(envId)
})
it("should do something", async () => {
const result = await runExpectSuccess(ImisApiService.myMethod(envId, "param"))
expect(result).toBeDefined()
})
})
Run integration tests:
bun test test/imis-api --timeout 30000
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience