@carthooks/arcubase-cli 0.1.25 → 0.1.26

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.
@@ -267,10 +267,10 @@ function renderDevSDKGenHelp() {
267
267
  ' - arcubase-admin dev sdk-gen --app-id <app_id> --out src/arcubase',
268
268
  '',
269
269
  'requirements:',
270
+ ' - every generated ingress must have a configured ingress.key; sdk-gen fails fast when keys are missing',
270
271
  ' - every generated field must have a configured field.key; sdk-gen fails fast when keys are missing',
271
- ' - existing field.key values must be stable unique TypeScript identifiers',
272
- ' - entity property names use entity.key when available, otherwise a stable entity<id> fallback',
273
- ' - generated code accepts createArcubaseSdk({ baseURL, accessToken, refreshToken })',
272
+ ' - ingress.key and field.key values must be stable unique TypeScript identifiers',
273
+ ' - generated code accepts createArcubaseClient({ baseURL, accessToken, refreshToken }).ingress("<IngressKey>")',
274
274
  ].join('\n');
275
275
  }
276
276
  function resolveEndpoint(command, flags) {
@@ -1679,6 +1679,89 @@ function assertSDKGenFieldKeysPresent(entity) {
1679
1679
  ],
1680
1680
  });
1681
1681
  }
1682
+ function extractSDKGenIngressRefs(payload) {
1683
+ const data = unwrapResponseData(payload);
1684
+ const source = Array.isArray(data)
1685
+ ? data
1686
+ : isRecord(data) && Array.isArray(data.list)
1687
+ ? data.list
1688
+ : [];
1689
+ return source.filter((item) => isRecord(item));
1690
+ }
1691
+ function ingressKeyOf(ingress) {
1692
+ return typeof ingress.key === 'string' ? ingress.key.trim() : '';
1693
+ }
1694
+ function ingressHashIDOf(ingress) {
1695
+ if (typeof ingress.hash_id === 'string' && ingress.hash_id.trim()) {
1696
+ return ingress.hash_id.trim();
1697
+ }
1698
+ if (typeof ingress.hashId === 'string' && ingress.hashId.trim()) {
1699
+ return ingress.hashId.trim();
1700
+ }
1701
+ return '';
1702
+ }
1703
+ function assertSDKGenIngressesReady(ingresses) {
1704
+ if (ingresses.length === 0) {
1705
+ throw new CLIError('SDK_GEN_NO_INGRESSES', 'sdk-gen could not find ingress definitions for this app', 2, {
1706
+ operation: 'dev sdk-gen',
1707
+ suggestions: ['create at least one access rule with a stable ingress.key before running sdk-gen'],
1708
+ });
1709
+ }
1710
+ const seen = new Set();
1711
+ const missingKey = [];
1712
+ const missingHash = [];
1713
+ const invalidKey = [];
1714
+ const duplicateKey = [];
1715
+ for (const ingress of ingresses) {
1716
+ const key = ingressKeyOf(ingress);
1717
+ if (!key) {
1718
+ missingKey.push(ingress);
1719
+ continue;
1720
+ }
1721
+ if (!/^[A-Za-z][A-Za-z0-9_]*$/.test(key)) {
1722
+ invalidKey.push(key);
1723
+ }
1724
+ if (seen.has(key)) {
1725
+ duplicateKey.push(key);
1726
+ }
1727
+ seen.add(key);
1728
+ if (!ingressHashIDOf(ingress)) {
1729
+ missingHash.push(ingress);
1730
+ }
1731
+ }
1732
+ if (missingKey.length > 0) {
1733
+ const preview = missingKey.slice(0, 8).map((ingress) => String(ingress.name ?? ingress.id ?? 'unnamed ingress'));
1734
+ const suffix = missingKey.length > preview.length ? `, and ${missingKey.length - preview.length} more` : '';
1735
+ throw new CLIError('SDK_GEN_INGRESS_KEY_REQUIRED', `missing ingress.key values: ${preview.join(', ')}${suffix}`, 2, {
1736
+ operation: 'dev sdk-gen',
1737
+ issues: missingKey.map((ingress) => ({
1738
+ path: `ingress.${String(ingress.id ?? 'unknown')}.key`,
1739
+ message: `ingress.key is required for ${String(ingress.name ?? ingress.id ?? 'unnamed ingress')}`,
1740
+ })),
1741
+ suggestions: [
1742
+ 'set stable ingress.key values in Arcubase admin before running sdk-gen',
1743
+ 'rerun arcubase-admin dev sdk-gen after ingress keys are complete',
1744
+ ],
1745
+ });
1746
+ }
1747
+ if (invalidKey.length > 0) {
1748
+ throw new CLIError('SDK_GEN_INVALID_INGRESS_KEY', `invalid ingress.key values: ${invalidKey.join(', ')}`, 2, {
1749
+ operation: 'dev sdk-gen',
1750
+ suggestions: ['use TypeScript identifier keys such as publicEntry or customerPortal'],
1751
+ });
1752
+ }
1753
+ if (duplicateKey.length > 0) {
1754
+ throw new CLIError('SDK_GEN_DUPLICATE_INGRESS_KEY', `duplicate ingress.key values: ${duplicateKey.join(', ')}`, 2, {
1755
+ operation: 'dev sdk-gen',
1756
+ });
1757
+ }
1758
+ if (missingHash.length > 0) {
1759
+ throw new CLIError('SDK_GEN_INGRESS_HASH_ID_REQUIRED', 'sdk-gen expected hash_id for every ingress definition', 2, {
1760
+ operation: 'dev sdk-gen',
1761
+ suggestions: ['upgrade Arcubase server so admin access-rule list returns hash_id'],
1762
+ });
1763
+ }
1764
+ }
1682
1765
  async function executeDevSDKGen(runtimeEnv, flags, fetchImpl) {
1683
1766
  validateDevSDKGenFlags(flags);
1684
1767
  const appId = flagValue(flags, 'app-id');
@@ -1705,7 +1788,7 @@ async function executeDevSDKGen(runtimeEnv, flags, fetchImpl) {
1705
1788
  if (entityRefs.length === 0) {
1706
1789
  throw new CLIError('SDK_GEN_NO_ENTITIES', 'sdk-gen could not find entities in app detail response', 2);
1707
1790
  }
1708
- const entities = [];
1791
+ const ingresses = [];
1709
1792
  for (const entityRef of entityRefs) {
1710
1793
  const entityEndpoint = `/api/apps/${encodeURIComponent(appId)}/entity/${encodeURIComponent(entityRef.id)}`;
1711
1794
  const entityDetail = await requestJSON(runtimeEnv, 'GET', entityEndpoint, undefined, fetchImpl);
@@ -1714,12 +1797,21 @@ async function executeDevSDKGen(runtimeEnv, flags, fetchImpl) {
1714
1797
  throw new CLIError('SDK_GEN_INVALID_SCHEMA', 'sdk-gen expected entity detail response data', 2);
1715
1798
  }
1716
1799
  assertSDKGenFieldKeysPresent(entityPayload);
1717
- entities.push(entityPayload);
1718
- }
1800
+ const ingressEndpoint = `/api/apps/${encodeURIComponent(appId)}/entity/${encodeURIComponent(entityRef.id)}/ingress`;
1801
+ const ingressList = await requestJSON(runtimeEnv, 'GET', ingressEndpoint, undefined, fetchImpl);
1802
+ const entityIngresses = extractSDKGenIngressRefs(ingressList.data).map((ingress) => ({
1803
+ ...ingress,
1804
+ hash_id: ingressHashIDOf(ingress),
1805
+ key: ingressKeyOf(ingress),
1806
+ entity: entityPayload,
1807
+ }));
1808
+ ingresses.push(...entityIngresses);
1809
+ }
1810
+ assertSDKGenIngressesReady(ingresses);
1719
1811
  const generated = generateArcubaseProjectSDK({
1720
1812
  id: resolveSDKGenAppId(appId, appPayload),
1721
1813
  name: typeof appPayload.name === 'string' ? appPayload.name : undefined,
1722
- entities,
1814
+ ingresses,
1723
1815
  });
1724
1816
  const absoluteOutDir = path.resolve(process.cwd(), outDir);
1725
1817
  for (const file of generated.files) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carthooks/arcubase-cli",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "Arcubase runtime CLI for admin and user command execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -31,7 +31,6 @@
31
31
  "docs:llms": "node -e \"\""
32
32
  },
33
33
  "dependencies": {
34
- "@arcubase/code-gen": "^0.1.0",
35
34
  "@carthooks/client-ts": "0.8.0",
36
35
  "zod": "^4.4.3"
37
36
  },
@@ -16,24 +16,26 @@ Workbench local ordinary-user codegen must not receive Arcubase admin tokens.
16
16
  It should use the BotWorks Host/JCode schema flow documented in
17
17
  `docs/design/workbench/03-workbench-vibe-coding-arcubase-codegen.md`.
18
18
 
19
- Generated code is key based. Application code uses stable `field.key` names, while generated runtime code converts those keys to internal numeric field ids.
20
- If any field is missing `field.key`, the command fails before generation and prints the missing fields. Set stable keys in Arcubase admin, then rerun the command.
19
+ Generated code is ingress and key based. Application code selects a stable `ingress.key`, then uses stable `field.key` names. Generated runtime code converts those keys to the internal ingress id and numeric field ids.
20
+ If any generated ingress is missing `ingress.key`, or any generated field is missing `field.key`, the command fails before generation and prints the missing keys. Set stable keys in Arcubase admin, then rerun the command.
21
21
 
22
22
  ```ts
23
- import { createArcubaseSdk } from './arcubase'
23
+ import { createArcubaseClient } from './arcubase'
24
24
 
25
- const sdk = createArcubaseSdk({
25
+ const client = createArcubaseClient({
26
26
  baseURL: 'https://team.example.arcubase.co/api',
27
27
  accessToken,
28
28
  refreshToken,
29
29
  })
30
30
 
31
- await sdk.story.create({
32
- story: 'Once upon a time',
31
+ const api = client.ingress('<IngressKey>')
32
+
33
+ await api.create({
34
+ '<FieldKey>': value,
33
35
  })
34
36
 
35
- await sdk.story.update(rowId, {
36
- story: 'Updated story',
37
+ await api.update(rowId, {
38
+ '<FieldKey>': nextValue,
37
39
  })
38
40
  ```
39
41
 
@@ -44,9 +46,11 @@ Arcubase runtime credentials in browser code.
44
46
 
45
47
  Rules:
46
48
 
49
+ - every generated ingress must have a configured `ingress.key`; sdk-gen does not invent fallback keys
47
50
  - every visible SDK field must have a configured `field.key`; sdk-gen does not invent fallback keys
48
- - existing `field.key` values must be stable unique TypeScript identifiers
51
+ - existing `ingress.key` and `field.key` values must be stable unique TypeScript identifiers
52
+ - `ingress.key` is the Web SDK entry contract and should not track display labels
49
53
  - `field.key` is a developer API contract and should not track display labels
50
- - entity property names use `entity.key` when available, otherwise a stable `entity<id>` fallback
54
+ - generated Web code starts from `createArcubaseClient(...).ingress('<IngressKey>')`, not entity CRUD
51
55
  - row create/update/query code should use generated types, not raw field ids
52
56
  - rerun the command after schema changes and commit the regenerated source with the Web project
@@ -34,13 +34,13 @@ export const PermitUserScopeSchema: z.ZodTypeAny = z.lazy(() => z.object({ "data
34
34
 
35
35
  export const EntityIngressOptionsSchema: z.ZodTypeAny = z.lazy(() => z.object({ "i18n_name": I18NTextSchema.optional(), "list_options": PermitEntityListOptionsSchema.optional(), "policy": PermitPolicySchema.optional(), "user_scope": z.array(PermitUserScopeSchema).optional() }).strict())
36
36
 
37
- export const AppIngressBulkApplyItemVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "rule_id": z.number().optional(), "table_id": z.number().optional(), "type": z.string().optional() }).strict())
37
+ export const AppIngressBulkApplyItemVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "key": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "rule_id": z.number().optional(), "table_id": z.number().optional(), "type": z.string().optional() }).strict())
38
38
 
39
39
  export const AppIngressBulkApplyReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "dry_run": z.boolean().optional(), "items": z.array(AppIngressBulkApplyItemVOSchema).optional(), "mode": z.string().optional() }).strict())
40
40
 
41
- export const AppIngressCreateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "entity_id": z.number().optional(), "icon_name": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "type": z.string().optional(), "url": z.string().optional() }).strict())
41
+ export const AppIngressCreateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "entity_id": z.number().optional(), "icon_name": z.string().optional(), "key": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "type": z.string().optional(), "url": z.string().optional() }).strict())
42
42
 
43
- export const AppIngressUpdateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "update": z.array(z.string()).optional() }).strict())
43
+ export const AppIngressUpdateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "key": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "update": z.array(z.string()).optional() }).strict())
44
44
 
45
45
  export const WidgetsTypeCodeSchema: z.ZodTypeAny = z.lazy(() => z.union([z.literal(1), z.literal(2)]))
46
46
 
@@ -50,6 +50,7 @@ export interface IngressItem {
50
50
  enabled?: boolean;
51
51
  i18n_name?: I18NText;
52
52
  id?: string;
53
+ key?: string;
53
54
  meta?: Record<string, any>;
54
55
  name?: string;
55
56
  type?: string;
@@ -23,7 +23,9 @@ export interface EntityIngress {
23
23
  app_id?: number;
24
24
  enabled?: boolean;
25
25
  entity_id?: number;
26
+ hash_id?: string;
26
27
  icon_name?: string;
28
+ key?: string;
27
29
  last_modified_by?: number;
28
30
  menu_group_id?: number;
29
31
  mode?: string;
@@ -64,6 +66,7 @@ export interface AppIngressBulkApplyItemRespVO {
64
66
 
65
67
  export interface AppIngressBulkApplyItemVO {
66
68
  enabled?: boolean;
69
+ key?: string;
67
70
  name?: string;
68
71
  options?: EntityIngressOptions;
69
72
  rule_id?: number;
@@ -88,6 +91,7 @@ export interface AppIngressCreateReqVO {
88
91
  enabled?: boolean;
89
92
  entity_id?: number;
90
93
  icon_name?: string;
94
+ key?: string;
91
95
  name?: string;
92
96
  options?: EntityIngressOptions;
93
97
  type?: string;
@@ -99,8 +103,10 @@ export interface AppIngressCreateRespVO {
99
103
  created_at?: number;
100
104
  enabled?: boolean;
101
105
  entity_id?: number;
106
+ hash_id?: string;
102
107
  icon_name?: string;
103
108
  id?: number;
109
+ key?: string;
104
110
  last_modified_by?: number;
105
111
  menu_group_id?: number;
106
112
  mode?: string;
@@ -117,8 +123,10 @@ export interface AppIngressDeleteRespVO {
117
123
  created_at?: number;
118
124
  enabled?: boolean;
119
125
  entity_id?: number;
126
+ hash_id?: string;
120
127
  icon_name?: string;
121
128
  id?: number;
129
+ key?: string;
122
130
  last_modified_by?: number;
123
131
  menu_group_id?: number;
124
132
  mode?: string;
@@ -135,8 +143,10 @@ export interface AppIngressGetByHashIDRespVO {
135
143
  created_at?: number;
136
144
  enabled?: boolean;
137
145
  entity_id?: number;
146
+ hash_id?: string;
138
147
  icon_name?: string;
139
148
  id?: number;
149
+ key?: string;
140
150
  last_modified_by?: number;
141
151
  menu_group_id?: number;
142
152
  mode?: string;
@@ -153,8 +163,10 @@ export interface AppIngressGetRespVO {
153
163
  created_at?: number;
154
164
  enabled?: boolean;
155
165
  entity_id?: number;
166
+ hash_id?: string;
156
167
  icon_name?: string;
157
168
  id?: number;
169
+ key?: string;
158
170
  last_modified_by?: number;
159
171
  menu_group_id?: number;
160
172
  mode?: string;
@@ -176,6 +188,7 @@ export interface AppIngressUpdateBlocksRespVO {
176
188
 
177
189
  export interface AppIngressUpdateReqVO {
178
190
  enabled?: boolean;
191
+ key?: string;
179
192
  name?: string;
180
193
  options?: EntityIngressOptions;
181
194
  update?: string[];
@@ -186,8 +199,10 @@ export interface AppIngressUpdateRespVO {
186
199
  created_at?: number;
187
200
  enabled?: boolean;
188
201
  entity_id?: number;
202
+ hash_id?: string;
189
203
  icon_name?: string;
190
204
  id?: number;
205
+ key?: string;
191
206
  last_modified_by?: number;
192
207
  menu_group_id?: number;
193
208
  mode?: string;
@@ -709,6 +709,7 @@ export interface IngressRespVO {
709
709
  has_admin?: boolean;
710
710
  id?: number;
711
711
  ingress?: {
712
+ key?: string;
712
713
  meta?: Record<string, any>;
713
714
  name?: string;
714
715
  };
@@ -34,13 +34,13 @@ export const PermitUserScopeSchema: z.ZodTypeAny = z.lazy(() => z.object({ "data
34
34
 
35
35
  export const EntityIngressOptionsSchema: z.ZodTypeAny = z.lazy(() => z.object({ "i18n_name": I18NTextSchema.optional(), "list_options": PermitEntityListOptionsSchema.optional(), "policy": PermitPolicySchema.optional(), "user_scope": z.array(PermitUserScopeSchema).optional() }).strict())
36
36
 
37
- export const AppIngressBulkApplyItemVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "rule_id": z.number().optional(), "table_id": z.number().optional(), "type": z.string().optional() }).strict())
37
+ export const AppIngressBulkApplyItemVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "key": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "rule_id": z.number().optional(), "table_id": z.number().optional(), "type": z.string().optional() }).strict())
38
38
 
39
39
  export const AppIngressBulkApplyReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "dry_run": z.boolean().optional(), "items": z.array(AppIngressBulkApplyItemVOSchema).optional(), "mode": z.string().optional() }).strict())
40
40
 
41
- export const AppIngressCreateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "entity_id": z.number().optional(), "icon_name": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "type": z.string().optional(), "url": z.string().optional() }).strict())
41
+ export const AppIngressCreateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "entity_id": z.number().optional(), "icon_name": z.string().optional(), "key": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "type": z.string().optional(), "url": z.string().optional() }).strict())
42
42
 
43
- export const AppIngressUpdateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "update": z.array(z.string()).optional() }).strict())
43
+ export const AppIngressUpdateReqVOSchema: z.ZodTypeAny = z.lazy(() => z.object({ "enabled": z.boolean().optional(), "key": z.string().optional(), "name": z.string().optional(), "options": EntityIngressOptionsSchema.optional(), "update": z.array(z.string()).optional() }).strict())
44
44
 
45
45
  export const WidgetsTypeCodeSchema: z.ZodTypeAny = z.lazy(() => z.union([z.literal(1), z.literal(2)]))
46
46