apaas-oapi-client 0.1.35 → 0.1.37
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/.vscode/settings.json +9 -0
- package/README.md +67 -5
- package/UserManual.md +6 -5
- package/dist/field-schema-rules.d.ts +35 -0
- package/dist/field-types.d.ts +313 -0
- package/dist/index.d.ts +313 -19
- package/dist/index.js +866 -5
- package/package.json +4 -5
- package/src/FIELD_SCHEMA_RULES.md +81 -0
- package/src/field-schema-rules.ts +336 -0
- package/src/field-types.ts +867 -0
- package/src/index.ts +312 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apaas-oapi-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
"type": "commonjs",
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "rollup -c",
|
|
13
|
-
"test": "jest",
|
|
14
|
-
"
|
|
15
|
-
"dev": "ts-node src/index.ts",
|
|
13
|
+
"test": "jest --passWithNoTests",
|
|
14
|
+
"dev": "tsx src/index.ts",
|
|
16
15
|
"release": "npm run build && npm version patch && git push origin main --follow-tags"
|
|
17
16
|
},
|
|
18
17
|
"keywords": [],
|
|
@@ -33,7 +32,7 @@
|
|
|
33
32
|
"rollup": "^4.44.1",
|
|
34
33
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
35
34
|
"ts-jest": "^29.4.0",
|
|
36
|
-
"
|
|
35
|
+
"tsx": "^4.21.0",
|
|
37
36
|
"typescript": "^5.8.3"
|
|
38
37
|
},
|
|
39
38
|
"description": ""
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Field Schema Rules (20 Entries)
|
|
2
|
+
|
|
3
|
+
This file summarizes the verified schema rules for field types in aPaaS.
|
|
4
|
+
|
|
5
|
+
- Verification date: `2026-02-10`
|
|
6
|
+
- Namespace: `package_5dc5b7__c`
|
|
7
|
+
- Source object for metadata: `full_field_format`
|
|
8
|
+
- Lookup target used in tests: `_user`
|
|
9
|
+
- Reference field target used in tests: `_lark_user_id`
|
|
10
|
+
|
|
11
|
+
## Why this file exists
|
|
12
|
+
|
|
13
|
+
`object.metadata.fields` returns type names that are not always accepted by `schema.create/schema.update`.
|
|
14
|
+
Use this mapping when creating fields.
|
|
15
|
+
|
|
16
|
+
- Includes `18` official metadata field types
|
|
17
|
+
- Plus `2` practical rule extensions:
|
|
18
|
+
- `text_multiline`
|
|
19
|
+
- `lookup_multi`
|
|
20
|
+
|
|
21
|
+
## Type Mapping (metadata -> create)
|
|
22
|
+
|
|
23
|
+
| Metadata Type | Create Type | Notes |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `text` | `text` | single-line text, `max_length=255` |
|
|
26
|
+
| `text_multiline` | `text` | multiline text, `multiline=true`, `max_length=100000` |
|
|
27
|
+
| `bigint` | `bigint` | same |
|
|
28
|
+
| `number` | `float` | `number` create type fails |
|
|
29
|
+
| `date` | `date` | same |
|
|
30
|
+
| `datetime` | `datetime` | same |
|
|
31
|
+
| `option` | `enum` | `option` create type fails |
|
|
32
|
+
| `boolean` | `boolean` | same |
|
|
33
|
+
| `lookup` | `lookup` | single value (`multiple=false`) |
|
|
34
|
+
| `lookup_multi` | `lookup` | multi value (`multiple=true`) |
|
|
35
|
+
| `referenceField` | `reference_field` | depends on lookup field |
|
|
36
|
+
| `file` | `attachment` | `file` create type fails |
|
|
37
|
+
| `autoId` | `auto_number` | `autoId` create type fails |
|
|
38
|
+
| `richText` | `richText` | same |
|
|
39
|
+
| `mobileNumber` | `phone` | `mobileNumber` create type fails |
|
|
40
|
+
| `avatarOrLogo` | `avatar` | `avatarOrLogo` create type fails |
|
|
41
|
+
| `email` | `email` | same |
|
|
42
|
+
| `region` | `region` | same |
|
|
43
|
+
| `decimal` | `decimal` | same |
|
|
44
|
+
| `multilingual` | `multilingual` | same |
|
|
45
|
+
|
|
46
|
+
## Dependency rules
|
|
47
|
+
|
|
48
|
+
- `lookup` needs target object to exist first. In tests, target object is `_user`.
|
|
49
|
+
- `lookup_multi` can reference multiple rows (`multiple=true`), but **cannot** be used as guide field for `reference_field`.
|
|
50
|
+
- `reference_field` needs:
|
|
51
|
+
- a **single-value** lookup field in the same object (`current_lookup_field_api_name`)
|
|
52
|
+
- a target field in target object (`target_reference_field_api_name`, tested with `_lark_user_id`)
|
|
53
|
+
|
|
54
|
+
## Option color list
|
|
55
|
+
|
|
56
|
+
Allowed option colors:
|
|
57
|
+
|
|
58
|
+
- `blue`
|
|
59
|
+
- `cyan`
|
|
60
|
+
- `green`
|
|
61
|
+
- `yellow`
|
|
62
|
+
- `orange`
|
|
63
|
+
- `red`
|
|
64
|
+
- `magenta`
|
|
65
|
+
- `purple`
|
|
66
|
+
- `blueMagenta`
|
|
67
|
+
- `grey`
|
|
68
|
+
|
|
69
|
+
## Batch update (`batch_update`) rules
|
|
70
|
+
|
|
71
|
+
- `add`: use `operator: "add"` and send full field definition.
|
|
72
|
+
- `replace`: use `operator: "replace"` and send full `type` (`name + settings`).
|
|
73
|
+
- Label-only replace (without `type`) fails with: `k_ec_000015 field type is required`.
|
|
74
|
+
- `remove`: use `operator: "remove"` and only `api_name`.
|
|
75
|
+
- Order constraints:
|
|
76
|
+
- add phase: create `lookup`/`lookup_multi` before `reference_field`
|
|
77
|
+
- remove phase: remove `reference_field` before `lookup`/`lookup_multi`
|
|
78
|
+
|
|
79
|
+
## Canonical machine-readable source
|
|
80
|
+
|
|
81
|
+
Use `/Users/Ethan/apaas/apaas-sdk/node-client/src/field-schema-rules.ts` as the source of truth for code.
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical field rules for schema.create/schema.update.
|
|
3
|
+
* Verified in namespace `package_5dc5b7__c` on 2026-02-10.
|
|
4
|
+
*
|
|
5
|
+
* Notes:
|
|
6
|
+
* - `metadataType` is usually the type name returned by object.metadata.fields.
|
|
7
|
+
* - Some entries are rule extensions for practical schema usage (`text_multiline`, `lookup_multi`).
|
|
8
|
+
* - `schemaType` is the type name that should be sent to schema.create/update.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export type MetadataFieldType =
|
|
12
|
+
| 'text'
|
|
13
|
+
| 'text_multiline'
|
|
14
|
+
| 'bigint'
|
|
15
|
+
| 'number'
|
|
16
|
+
| 'date'
|
|
17
|
+
| 'datetime'
|
|
18
|
+
| 'option'
|
|
19
|
+
| 'boolean'
|
|
20
|
+
| 'lookup'
|
|
21
|
+
| 'lookup_multi'
|
|
22
|
+
| 'referenceField'
|
|
23
|
+
| 'file'
|
|
24
|
+
| 'autoId'
|
|
25
|
+
| 'richText'
|
|
26
|
+
| 'mobileNumber'
|
|
27
|
+
| 'avatarOrLogo'
|
|
28
|
+
| 'email'
|
|
29
|
+
| 'region'
|
|
30
|
+
| 'decimal'
|
|
31
|
+
| 'multilingual';
|
|
32
|
+
|
|
33
|
+
export type SchemaFieldType =
|
|
34
|
+
| 'text'
|
|
35
|
+
| 'bigint'
|
|
36
|
+
| 'float'
|
|
37
|
+
| 'date'
|
|
38
|
+
| 'datetime'
|
|
39
|
+
| 'enum'
|
|
40
|
+
| 'boolean'
|
|
41
|
+
| 'lookup'
|
|
42
|
+
| 'reference_field'
|
|
43
|
+
| 'attachment'
|
|
44
|
+
| 'auto_number'
|
|
45
|
+
| 'richText'
|
|
46
|
+
| 'phone'
|
|
47
|
+
| 'avatar'
|
|
48
|
+
| 'email'
|
|
49
|
+
| 'region'
|
|
50
|
+
| 'decimal'
|
|
51
|
+
| 'multilingual';
|
|
52
|
+
|
|
53
|
+
export interface FieldCreateRule {
|
|
54
|
+
metadataType: MetadataFieldType;
|
|
55
|
+
schemaType: SchemaFieldType;
|
|
56
|
+
settingsExample: Record<string, unknown>;
|
|
57
|
+
dependsOn?: string[];
|
|
58
|
+
notes?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const SCHEMA_TYPE_BY_METADATA_TYPE: Record<MetadataFieldType, SchemaFieldType> = {
|
|
62
|
+
text: 'text',
|
|
63
|
+
text_multiline: 'text',
|
|
64
|
+
bigint: 'bigint',
|
|
65
|
+
number: 'float',
|
|
66
|
+
date: 'date',
|
|
67
|
+
datetime: 'datetime',
|
|
68
|
+
option: 'enum',
|
|
69
|
+
boolean: 'boolean',
|
|
70
|
+
lookup: 'lookup',
|
|
71
|
+
lookup_multi: 'lookup',
|
|
72
|
+
referenceField: 'reference_field',
|
|
73
|
+
file: 'attachment',
|
|
74
|
+
autoId: 'auto_number',
|
|
75
|
+
richText: 'richText',
|
|
76
|
+
mobileNumber: 'phone',
|
|
77
|
+
avatarOrLogo: 'avatar',
|
|
78
|
+
email: 'email',
|
|
79
|
+
region: 'region',
|
|
80
|
+
decimal: 'decimal',
|
|
81
|
+
multilingual: 'multilingual'
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const OPTION_COLOR_LIST = [
|
|
85
|
+
'blue',
|
|
86
|
+
'cyan',
|
|
87
|
+
'green',
|
|
88
|
+
'yellow',
|
|
89
|
+
'orange',
|
|
90
|
+
'red',
|
|
91
|
+
'magenta',
|
|
92
|
+
'purple',
|
|
93
|
+
'blueMagenta',
|
|
94
|
+
'grey'
|
|
95
|
+
] as const;
|
|
96
|
+
|
|
97
|
+
export const FIELD_SCHEMA_RULES: FieldCreateRule[] = [
|
|
98
|
+
{
|
|
99
|
+
metadataType: 'text',
|
|
100
|
+
schemaType: 'text',
|
|
101
|
+
settingsExample: {
|
|
102
|
+
required: false,
|
|
103
|
+
unique: false,
|
|
104
|
+
case_sensitive: false,
|
|
105
|
+
multiline: false,
|
|
106
|
+
max_length: 255
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
metadataType: 'text_multiline',
|
|
111
|
+
schemaType: 'text',
|
|
112
|
+
settingsExample: {
|
|
113
|
+
required: false,
|
|
114
|
+
unique: false,
|
|
115
|
+
case_sensitive: false,
|
|
116
|
+
multiline: true,
|
|
117
|
+
max_length: 100000
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
metadataType: 'bigint',
|
|
122
|
+
schemaType: 'bigint',
|
|
123
|
+
settingsExample: {
|
|
124
|
+
required: false,
|
|
125
|
+
unique: false
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
metadataType: 'number',
|
|
130
|
+
schemaType: 'float',
|
|
131
|
+
settingsExample: {
|
|
132
|
+
required: false,
|
|
133
|
+
unique: false,
|
|
134
|
+
display_as_percentage: false,
|
|
135
|
+
decimal_places_number: 2
|
|
136
|
+
},
|
|
137
|
+
notes: 'Do not send create type as `number`.'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
metadataType: 'date',
|
|
141
|
+
schemaType: 'date',
|
|
142
|
+
settingsExample: {
|
|
143
|
+
required: false
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
metadataType: 'datetime',
|
|
148
|
+
schemaType: 'datetime',
|
|
149
|
+
settingsExample: {
|
|
150
|
+
required: false
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
metadataType: 'option',
|
|
155
|
+
schemaType: 'enum',
|
|
156
|
+
settingsExample: {
|
|
157
|
+
required: false,
|
|
158
|
+
multiple: false,
|
|
159
|
+
option_source: 'custom',
|
|
160
|
+
global_option_api_name: '',
|
|
161
|
+
options: [
|
|
162
|
+
{
|
|
163
|
+
label: { zh_cn: 'Option One', en_us: 'Option One' },
|
|
164
|
+
api_name: 'option_one',
|
|
165
|
+
description: null,
|
|
166
|
+
color: 'blue',
|
|
167
|
+
active: true
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
label: { zh_cn: 'Option Two', en_us: 'Option Two' },
|
|
171
|
+
api_name: 'option_two',
|
|
172
|
+
description: null,
|
|
173
|
+
color: 'green',
|
|
174
|
+
active: true
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
notes: `Do not send create type as \`option\`. Available option colors: ${OPTION_COLOR_LIST.join(', ')}.`
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
metadataType: 'boolean',
|
|
182
|
+
schemaType: 'boolean',
|
|
183
|
+
settingsExample: {
|
|
184
|
+
default_value: true,
|
|
185
|
+
description_if_true: { zh_cn: '1', en_us: '1' },
|
|
186
|
+
description_if_false: { zh_cn: '0', en_us: '0' }
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
metadataType: 'lookup',
|
|
191
|
+
schemaType: 'lookup',
|
|
192
|
+
settingsExample: {
|
|
193
|
+
required: false,
|
|
194
|
+
multiple: false,
|
|
195
|
+
referenced_object_api_name: '_user',
|
|
196
|
+
display_as_tree: false,
|
|
197
|
+
display_style: 'select'
|
|
198
|
+
},
|
|
199
|
+
dependsOn: ['Target object must exist first: `_user`'],
|
|
200
|
+
notes: 'Single-value lookup (`multiple: false`), can be used by `reference_field`.'
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
metadataType: 'lookup_multi',
|
|
204
|
+
schemaType: 'lookup',
|
|
205
|
+
settingsExample: {
|
|
206
|
+
required: false,
|
|
207
|
+
multiple: true,
|
|
208
|
+
referenced_object_api_name: '_user',
|
|
209
|
+
display_as_tree: false,
|
|
210
|
+
display_style: 'select'
|
|
211
|
+
},
|
|
212
|
+
dependsOn: ['Target object must exist first: `_user`'],
|
|
213
|
+
notes: 'Multi-value lookup (`multiple: true`) cannot be used by `reference_field`.'
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
metadataType: 'referenceField',
|
|
217
|
+
schemaType: 'reference_field',
|
|
218
|
+
settingsExample: {
|
|
219
|
+
current_lookup_field_api_name: 'lookup_835c2a2457b',
|
|
220
|
+
target_reference_field_api_name: '_lark_user_id'
|
|
221
|
+
},
|
|
222
|
+
dependsOn: [
|
|
223
|
+
'A single-value lookup field must exist first in the same object',
|
|
224
|
+
'The target field must exist in the lookup target object'
|
|
225
|
+
],
|
|
226
|
+
notes: 'Guide field must be single lookup (`multiple: false`).'
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
metadataType: 'file',
|
|
230
|
+
schemaType: 'attachment',
|
|
231
|
+
settingsExample: {
|
|
232
|
+
required: false,
|
|
233
|
+
any_type: true,
|
|
234
|
+
max_uploaded_num: 10,
|
|
235
|
+
mime_types: []
|
|
236
|
+
},
|
|
237
|
+
notes: 'Do not send create type as `file`.'
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
metadataType: 'autoId',
|
|
241
|
+
schemaType: 'auto_number',
|
|
242
|
+
settingsExample: {
|
|
243
|
+
generation_method: 'random',
|
|
244
|
+
digits: 1,
|
|
245
|
+
prefix: '',
|
|
246
|
+
suffix: '',
|
|
247
|
+
start_at: '1'
|
|
248
|
+
},
|
|
249
|
+
notes: 'Do not send create type as `autoId`.'
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
metadataType: 'richText',
|
|
253
|
+
schemaType: 'richText',
|
|
254
|
+
settingsExample: {
|
|
255
|
+
required: false,
|
|
256
|
+
max_length: 1000
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
metadataType: 'mobileNumber',
|
|
261
|
+
schemaType: 'phone',
|
|
262
|
+
settingsExample: {
|
|
263
|
+
required: false,
|
|
264
|
+
unique: false
|
|
265
|
+
},
|
|
266
|
+
notes: 'Do not send create type as `mobileNumber`.'
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
metadataType: 'avatarOrLogo',
|
|
270
|
+
schemaType: 'avatar',
|
|
271
|
+
settingsExample: {
|
|
272
|
+
display_style: 'square'
|
|
273
|
+
},
|
|
274
|
+
notes: 'Do not send create type as `avatarOrLogo`.'
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
metadataType: 'email',
|
|
278
|
+
schemaType: 'email',
|
|
279
|
+
settingsExample: {
|
|
280
|
+
required: false,
|
|
281
|
+
unique: false
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
metadataType: 'region',
|
|
286
|
+
schemaType: 'region',
|
|
287
|
+
settingsExample: {
|
|
288
|
+
required: false,
|
|
289
|
+
multiple: false,
|
|
290
|
+
has_level_strict: true,
|
|
291
|
+
strict_level: 4
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
metadataType: 'decimal',
|
|
296
|
+
schemaType: 'decimal',
|
|
297
|
+
settingsExample: {
|
|
298
|
+
required: false,
|
|
299
|
+
unique: false,
|
|
300
|
+
display_as_percentage: false,
|
|
301
|
+
decimal_places: 2
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
metadataType: 'multilingual',
|
|
306
|
+
schemaType: 'multilingual',
|
|
307
|
+
settingsExample: {
|
|
308
|
+
required: false,
|
|
309
|
+
unique: false,
|
|
310
|
+
case_sensitive: false,
|
|
311
|
+
multiline: false,
|
|
312
|
+
max_length: 1000
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
];
|
|
316
|
+
|
|
317
|
+
export const SCHEMA_TYPE_MISMATCHES: Array<{
|
|
318
|
+
metadataType: MetadataFieldType;
|
|
319
|
+
schemaType: SchemaFieldType;
|
|
320
|
+
}> = FIELD_SCHEMA_RULES
|
|
321
|
+
.filter((rule) => rule.metadataType !== rule.schemaType)
|
|
322
|
+
.map((rule) => ({
|
|
323
|
+
metadataType: rule.metadataType,
|
|
324
|
+
schemaType: rule.schemaType
|
|
325
|
+
}));
|
|
326
|
+
|
|
327
|
+
export const BATCH_UPDATE_REQUIREMENTS = {
|
|
328
|
+
add: 'Use operator=add with full field definition.',
|
|
329
|
+
replace: 'Use operator=replace and include full `type` (name + settings). Label-only replace fails.',
|
|
330
|
+
remove: 'Use operator=remove with api_name only.',
|
|
331
|
+
dependencyOrder: {
|
|
332
|
+
add: ['lookup/lookup_multi before reference_field'],
|
|
333
|
+
remove: ['reference_field before lookup/lookup_multi']
|
|
334
|
+
},
|
|
335
|
+
referenceFieldConstraint: 'reference_field only works with single lookup (`multiple: false`).'
|
|
336
|
+
} as const;
|