apaas-oapi-client 0.1.37 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/bin/apaas-oapi-client.js +129 -0
- package/package.json +17 -3
- package/skills/apaas-builder/SKILL.md +43 -0
- package/skills/apaas-builder/agents/openai.yaml +4 -0
- package/skills/apaas-exchange-attachment/SKILL.md +59 -0
- package/skills/apaas-exchange-attachment/agents/openai.yaml +4 -0
- package/skills/apaas-function-flow/SKILL.md +50 -0
- package/skills/apaas-function-flow/agents/openai.yaml +4 -0
- package/skills/apaas-global/SKILL.md +43 -0
- package/skills/apaas-global/agents/openai.yaml +4 -0
- package/skills/apaas-object/SKILL.md +99 -0
- package/skills/apaas-object/agents/openai.yaml +4 -0
- package/skills/apaas-schema/SKILL.md +77 -0
- package/skills/apaas-schema/agents/openai.yaml +4 -0
- package/skills/apaas-schema/references/field-schema-rules.md +98 -0
- package/skills/apaas-shared/SKILL.md +56 -0
- package/skills/apaas-shared/agents/openai.yaml +4 -0
- package/.env +0 -5
- package/.github/workflows/publish.yml +0 -36
- package/.vscode/settings.json +0 -9
- package/dist/src/index.d.ts +0 -674
- package/dist/src/limiter.d.ts +0 -17
- package/dist/src/logger.d.ts +0 -11
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Field Schema Rules
|
|
2
|
+
|
|
3
|
+
Use this reference before `client.schema.create` or `client.schema.update` field changes.
|
|
4
|
+
|
|
5
|
+
- Verified source in this repo: `src/FIELD_SCHEMA_RULES.md`
|
|
6
|
+
- Machine-readable source: `src/field-schema-rules.ts`
|
|
7
|
+
- Verification date in source: `2026-02-10`
|
|
8
|
+
|
|
9
|
+
## Metadata To Create Type Mapping
|
|
10
|
+
|
|
11
|
+
| Metadata Type | Create Type | Notes |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `text` | `text` | Single-line text, commonly `max_length=255`. |
|
|
14
|
+
| `text_multiline` | `text` | Use `multiline=true`, commonly `max_length=100000`. |
|
|
15
|
+
| `bigint` | `bigint` | Same type name. |
|
|
16
|
+
| `number` | `float` | `number` create type fails. |
|
|
17
|
+
| `date` | `date` | Same type name. |
|
|
18
|
+
| `datetime` | `datetime` | Same type name. |
|
|
19
|
+
| `option` | `enum` | `option` create type fails. |
|
|
20
|
+
| `boolean` | `boolean` | Same type name. |
|
|
21
|
+
| `lookup` | `lookup` | Single value, `multiple=false`. |
|
|
22
|
+
| `lookup_multi` | `lookup` | Multi value, `multiple=true`. |
|
|
23
|
+
| `referenceField` | `reference_field` | Depends on a single-value lookup field. |
|
|
24
|
+
| `file` | `attachment` | `file` create type fails. |
|
|
25
|
+
| `autoId` | `auto_number` | `autoId` create type fails. |
|
|
26
|
+
| `richText` | `richText` | Same type name. |
|
|
27
|
+
| `mobileNumber` | `phone` | `mobileNumber` create type fails. |
|
|
28
|
+
| `avatarOrLogo` | `avatar` | `avatarOrLogo` create type fails. |
|
|
29
|
+
| `email` | `email` | Same type name. |
|
|
30
|
+
| `region` | `region` | Same type name. |
|
|
31
|
+
| `decimal` | `decimal` | Same type name. |
|
|
32
|
+
| `multilingual` | `multilingual` | Same type name. |
|
|
33
|
+
|
|
34
|
+
## Dependency Rules
|
|
35
|
+
|
|
36
|
+
- Create target objects before lookup fields that reference them.
|
|
37
|
+
- Create `lookup` or `lookup_multi` before `reference_field`.
|
|
38
|
+
- Use only a single-value `lookup` as `reference_field.current_lookup_field_api_name`.
|
|
39
|
+
- Do not use `lookup_multi` as the guide field for `reference_field`.
|
|
40
|
+
- Remove `reference_field` before removing its lookup field.
|
|
41
|
+
|
|
42
|
+
## Batch Update Rules
|
|
43
|
+
|
|
44
|
+
- `add`: use `operator: "add"` and send the full field definition.
|
|
45
|
+
- `replace`: use `operator: "replace"` and send full `type.name` plus `type.settings`.
|
|
46
|
+
- `remove`: use `operator: "remove"` and send only `api_name`.
|
|
47
|
+
- Label-only replace without `type` fails with `k_ec_000015 field type is required`.
|
|
48
|
+
|
|
49
|
+
## Option Colors
|
|
50
|
+
|
|
51
|
+
Allowed option colors:
|
|
52
|
+
|
|
53
|
+
- `blue`
|
|
54
|
+
- `cyan`
|
|
55
|
+
- `green`
|
|
56
|
+
- `yellow`
|
|
57
|
+
- `orange`
|
|
58
|
+
- `red`
|
|
59
|
+
- `magenta`
|
|
60
|
+
- `purple`
|
|
61
|
+
- `blueMagenta`
|
|
62
|
+
- `grey`
|
|
63
|
+
|
|
64
|
+
## Minimal Lookup Example
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
{
|
|
68
|
+
operator: "add",
|
|
69
|
+
api_name: "owner",
|
|
70
|
+
label: { zh_cn: "负责人", en_us: "Owner" },
|
|
71
|
+
type: {
|
|
72
|
+
name: "lookup",
|
|
73
|
+
settings: {
|
|
74
|
+
objectAPIName: "_user",
|
|
75
|
+
multiple: false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
encrypt_type: "none"
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Minimal Reference Field Example
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
{
|
|
86
|
+
operator: "add",
|
|
87
|
+
api_name: "owner_lark_id",
|
|
88
|
+
label: { zh_cn: "负责人飞书 ID", en_us: "Owner Lark ID" },
|
|
89
|
+
type: {
|
|
90
|
+
name: "reference_field",
|
|
91
|
+
settings: {
|
|
92
|
+
current_lookup_field_api_name: "owner",
|
|
93
|
+
target_reference_field_api_name: "_lark_user_id"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
encrypt_type: "none"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: apaas-shared
|
|
3
|
+
description: "Use for aPaaS Node SDK shared setup and safety rules: client initialization, credentials, namespace, token cache, logger level, pagination defaults, retry expectations, write/delete confirmation, and error triage before using module-specific apaas skills."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# aPaaS Shared
|
|
7
|
+
|
|
8
|
+
Use this skill before module-specific aPaaS SDK work.
|
|
9
|
+
|
|
10
|
+
## Baseline
|
|
11
|
+
|
|
12
|
+
- Use the Node SDK package `apaas-oapi-client`.
|
|
13
|
+
- Initialize one `apaas.Client` per namespace.
|
|
14
|
+
- Keep `clientId`, `clientSecret`, access tokens, and app secrets out of logs and final answers.
|
|
15
|
+
- Prefer `client.setLoggerLevel(3)` for normal work, `4` for debugging, and `5` only when inspecting non-sensitive payloads.
|
|
16
|
+
- Treat SDK responses with `code !== "0"` as failed even if the HTTP call succeeded.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { apaas } from "apaas-oapi-client";
|
|
20
|
+
|
|
21
|
+
const client = new apaas.Client({
|
|
22
|
+
clientId: process.env.APAAS_CLIENT_ID!,
|
|
23
|
+
clientSecret: process.env.APAAS_CLIENT_SECRET!,
|
|
24
|
+
namespace: process.env.APAAS_NAMESPACE!
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
await client.init();
|
|
28
|
+
client.setLoggerLevel(3);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Safety Rules
|
|
32
|
+
|
|
33
|
+
- Read real metadata before writing records, fields, flows, or pages.
|
|
34
|
+
- Confirm user intent before destructive calls: record delete, batch delete, schema delete, field remove, attachment delete.
|
|
35
|
+
- For batch operations, inspect `failed`, `failedCount`, or per-item success fields before reporting completion.
|
|
36
|
+
- For full-table answers, use iterator methods and verify pagination is exhausted; a single page is only a sample.
|
|
37
|
+
- Do not write system fields, readonly fields, formula outputs, lookup outputs, or reference field outputs as ordinary record values.
|
|
38
|
+
|
|
39
|
+
## Module Routing
|
|
40
|
+
|
|
41
|
+
- Object metadata and record CRUD: use `apaas-object`.
|
|
42
|
+
- Object and field schema changes: use `apaas-schema`.
|
|
43
|
+
- Cloud functions and automation flows: use `apaas-function-flow`.
|
|
44
|
+
- Builder page metadata and links: use `apaas-builder`.
|
|
45
|
+
- Global options and variables: use `apaas-global`.
|
|
46
|
+
- User/department ID exchange and attachments: use `apaas-exchange-attachment`.
|
|
47
|
+
|
|
48
|
+
## Error Triage
|
|
49
|
+
|
|
50
|
+
| Symptom | First action |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| Permission or scope error | Verify app permissions and namespace; do not retry blindly. |
|
|
53
|
+
| Field value type mismatch | Re-read `client.object.metadata.fields({ object_name })`. |
|
|
54
|
+
| Missing field/object | Re-read object list or metadata; use API names from returned data. |
|
|
55
|
+
| Batch partially failed | Report failed items and retry only failed IDs/records when safe. |
|
|
56
|
+
| Rate limit or transient 5xx | Use SDK iterator/batch helpers and retry only idempotent reads or confirmed-safe writes. |
|
package/.env
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
name: Node.js CI & Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build-test-publish:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
|
|
11
|
-
strategy:
|
|
12
|
-
matrix:
|
|
13
|
-
node-version: [22.x]
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v3
|
|
17
|
-
|
|
18
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
19
|
-
uses: actions/setup-node@v3
|
|
20
|
-
with:
|
|
21
|
-
node-version: ${{ matrix.node-version }}
|
|
22
|
-
registry-url: 'https://registry.npmjs.org/'
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm install
|
|
26
|
-
|
|
27
|
-
- name: Build
|
|
28
|
-
run: npm run build
|
|
29
|
-
|
|
30
|
-
- name: Run Tests
|
|
31
|
-
run: npm test
|
|
32
|
-
|
|
33
|
-
- name: Publish to npm
|
|
34
|
-
run: npm publish --access public
|
|
35
|
-
env:
|
|
36
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.vscode/settings.json
DELETED