@customyai/cli 0.1.0

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.
@@ -0,0 +1,301 @@
1
+ import { z } from 'zod';
2
+
3
+ type CliIo = {
4
+ cwd: string;
5
+ env: Record<string, string | undefined>;
6
+ out: (line: string) => void;
7
+ err: (line: string) => void;
8
+ fetch?: typeof fetch;
9
+ };
10
+ declare function runCli(argv: string[], io: CliIo): Promise<number>;
11
+
12
+ /**
13
+ * Manifiesto de aplicación `app/v1` — el `customy.app.json` que versiona cada
14
+ * app del ecosistema (ADR CUSTOMY_SDK_PLATFORM_DECISION_2026-09-24, D3).
15
+ *
16
+ * Declara qué productos usa la app y con qué scopes, qué recursos enlaza
17
+ * (validados contra el `product/v1` de cada producto), qué eventos emite con su
18
+ * schema y propósito de consentimiento, y sus capabilities, planes y meters.
19
+ * `customy apps sync` lo reconcilia; ningún servicio de Customy conoce apps por nombre.
20
+ */
21
+
22
+ declare const AppManifestSchema: z.ZodObject<{
23
+ /** Referencia opcional al JSON Schema publicado, para autocompletado en editores. */
24
+ $schema: z.ZodOptional<z.ZodString>;
25
+ schema: z.ZodLiteral<"app/v1">;
26
+ key: z.ZodString;
27
+ name: z.ZodString;
28
+ origins: z.ZodEffects<z.ZodObject<{
29
+ staging: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
30
+ production: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
31
+ }, "strict", z.ZodTypeAny, {
32
+ staging?: string | undefined;
33
+ production?: string | undefined;
34
+ }, {
35
+ staging?: string | undefined;
36
+ production?: string | undefined;
37
+ }>, {
38
+ staging?: string | undefined;
39
+ production?: string | undefined;
40
+ }, {
41
+ staging?: string | undefined;
42
+ production?: string | undefined;
43
+ }>;
44
+ products: z.ZodDefault<z.ZodArray<z.ZodObject<{
45
+ product: z.ZodString;
46
+ /** Scopes de producto que pedirán sus credenciales de máquina (`<producto>:<scope>`). */
47
+ scopes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
48
+ }, "strict", z.ZodTypeAny, {
49
+ product: string;
50
+ scopes: string[];
51
+ }, {
52
+ product: string;
53
+ scopes?: string[] | undefined;
54
+ }>, "many">>;
55
+ resources: z.ZodDefault<z.ZodArray<z.ZodObject<{
56
+ key: z.ZodString;
57
+ product: z.ZodString;
58
+ bindingKind: z.ZodOptional<z.ZodEnum<["product", "internal_service", "external_destination", "public_form", "private_collection", "external_source", "external_automation", "external_communication"]>>;
59
+ operations: z.ZodOptional<z.ZodArray<z.ZodEnum<["read", "propose", "submit", "read_owned", "write_owned", "research", "deliver_budget_alert", "deliver_notification"]>, "many">>;
60
+ }, "strict", z.ZodTypeAny, {
61
+ product: string;
62
+ key: string;
63
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
64
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
65
+ }, {
66
+ product: string;
67
+ key: string;
68
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
69
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
70
+ }>, "many">>;
71
+ events: z.ZodDefault<z.ZodArray<z.ZodObject<{
72
+ name: z.ZodString;
73
+ type: z.ZodEnum<["track", "identify", "group", "page", "screen", "alias"]>;
74
+ schemaVersion: z.ZodNumber;
75
+ /** JSON Schema de `properties`; se publica como schema fijado del evento. */
76
+ properties: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
77
+ purposes: z.ZodArray<z.ZodString, "many">;
78
+ }, "strict", z.ZodTypeAny, {
79
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
80
+ name: string;
81
+ schemaVersion: number;
82
+ properties: Record<string, unknown>;
83
+ purposes: string[];
84
+ }, {
85
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
86
+ name: string;
87
+ schemaVersion: number;
88
+ purposes: string[];
89
+ properties?: Record<string, unknown> | undefined;
90
+ }>, "many">>;
91
+ capabilities: z.ZodDefault<z.ZodArray<z.ZodObject<{
92
+ lookupKey: z.ZodString;
93
+ name: z.ZodString;
94
+ type: z.ZodEnum<["boolean", "metered", "config"]>;
95
+ meter: z.ZodOptional<z.ZodString>;
96
+ }, "strict", z.ZodTypeAny, {
97
+ type: "boolean" | "metered" | "config";
98
+ name: string;
99
+ lookupKey: string;
100
+ meter?: string | undefined;
101
+ }, {
102
+ type: "boolean" | "metered" | "config";
103
+ name: string;
104
+ lookupKey: string;
105
+ meter?: string | undefined;
106
+ }>, "many">>;
107
+ plans: z.ZodDefault<z.ZodArray<z.ZodObject<{
108
+ code: z.ZodString;
109
+ name: z.ZodString;
110
+ rank: z.ZodDefault<z.ZodNumber>;
111
+ capabilities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
+ }, "strict", z.ZodTypeAny, {
113
+ code: string;
114
+ name: string;
115
+ rank: number;
116
+ capabilities: Record<string, unknown>;
117
+ }, {
118
+ code: string;
119
+ name: string;
120
+ rank?: number | undefined;
121
+ capabilities?: Record<string, unknown> | undefined;
122
+ }>, "many">>;
123
+ meters: z.ZodDefault<z.ZodArray<z.ZodObject<{
124
+ code: z.ZodString;
125
+ aggregation: z.ZodEnum<["sum", "count", "last"]>;
126
+ unit: z.ZodString;
127
+ }, "strict", z.ZodTypeAny, {
128
+ code: string;
129
+ aggregation: "sum" | "count" | "last";
130
+ unit: string;
131
+ }, {
132
+ code: string;
133
+ aggregation: "sum" | "count" | "last";
134
+ unit: string;
135
+ }>, "many">>;
136
+ }, "strict", z.ZodTypeAny, {
137
+ schema: "app/v1";
138
+ key: string;
139
+ name: string;
140
+ capabilities: {
141
+ type: "boolean" | "metered" | "config";
142
+ name: string;
143
+ lookupKey: string;
144
+ meter?: string | undefined;
145
+ }[];
146
+ origins: {
147
+ staging?: string | undefined;
148
+ production?: string | undefined;
149
+ };
150
+ products: {
151
+ product: string;
152
+ scopes: string[];
153
+ }[];
154
+ resources: {
155
+ product: string;
156
+ key: string;
157
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
158
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
159
+ }[];
160
+ events: {
161
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
162
+ name: string;
163
+ schemaVersion: number;
164
+ properties: Record<string, unknown>;
165
+ purposes: string[];
166
+ }[];
167
+ plans: {
168
+ code: string;
169
+ name: string;
170
+ rank: number;
171
+ capabilities: Record<string, unknown>;
172
+ }[];
173
+ meters: {
174
+ code: string;
175
+ aggregation: "sum" | "count" | "last";
176
+ unit: string;
177
+ }[];
178
+ $schema?: string | undefined;
179
+ }, {
180
+ schema: "app/v1";
181
+ key: string;
182
+ name: string;
183
+ origins: {
184
+ staging?: string | undefined;
185
+ production?: string | undefined;
186
+ };
187
+ capabilities?: {
188
+ type: "boolean" | "metered" | "config";
189
+ name: string;
190
+ lookupKey: string;
191
+ meter?: string | undefined;
192
+ }[] | undefined;
193
+ $schema?: string | undefined;
194
+ products?: {
195
+ product: string;
196
+ scopes?: string[] | undefined;
197
+ }[] | undefined;
198
+ resources?: {
199
+ product: string;
200
+ key: string;
201
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
202
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
203
+ }[] | undefined;
204
+ events?: {
205
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
206
+ name: string;
207
+ schemaVersion: number;
208
+ purposes: string[];
209
+ properties?: Record<string, unknown> | undefined;
210
+ }[] | undefined;
211
+ plans?: {
212
+ code: string;
213
+ name: string;
214
+ rank?: number | undefined;
215
+ capabilities?: Record<string, unknown> | undefined;
216
+ }[] | undefined;
217
+ meters?: {
218
+ code: string;
219
+ aggregation: "sum" | "count" | "last";
220
+ unit: string;
221
+ }[] | undefined;
222
+ }>;
223
+ type AppManifest = z.infer<typeof AppManifestSchema>;
224
+
225
+ /**
226
+ * `customy apps validate | sync`: reconcilia el `customy.app.json` de una app
227
+ * con Customy Access (ADR SDK, D3).
228
+ *
229
+ * `sync` es idempotente: instala la app en el Workspace si no existe (el
230
+ * install repetido devuelve la misma conexión) y, si el manifiesto cambió,
231
+ * publica una versión nueva sobre la revisión actual. Access lleva después el
232
+ * manifiesto a los productos (los `events` a Data) y devuelve cómo fue; repetir
233
+ * `sync` con el mismo manifiesto repara una reconciliación fallida. Nunca crea
234
+ * credenciales: eso lo decide un administrador del Workspace.
235
+ */
236
+
237
+ type Problem = {
238
+ path: string;
239
+ code: string;
240
+ };
241
+ declare function validateManifest(input: unknown): {
242
+ ok: true;
243
+ manifest: AppManifest;
244
+ } | {
245
+ ok: false;
246
+ problems: Problem[];
247
+ };
248
+ type SyncOptions = {
249
+ manifest: AppManifest;
250
+ accessUrl: string;
251
+ token: string;
252
+ workspaceEnvironmentId: string;
253
+ reason: string;
254
+ fetch?: typeof fetch;
255
+ };
256
+ type ProductReconciliation = {
257
+ status: "skipped";
258
+ reason: string;
259
+ } | {
260
+ status: "reconciled";
261
+ changed: boolean;
262
+ resourceId?: string;
263
+ } | {
264
+ status: "failed";
265
+ code: string;
266
+ };
267
+ type SyncResult = {
268
+ action: "installed" | "updated" | "unchanged";
269
+ applicationId: string;
270
+ environmentId: string;
271
+ revision: number;
272
+ /** Cómo quedó cada producto; vacío si Access no lo informa. */
273
+ reconciliation: Record<string, ProductReconciliation>;
274
+ };
275
+ declare class SyncError extends Error {
276
+ readonly code: string;
277
+ readonly status: number;
278
+ constructor(code: string, status: number);
279
+ }
280
+ declare function syncApp(options: SyncOptions): Promise<SyncResult>;
281
+
282
+ /**
283
+ * Tipos de una app a partir de su manifiesto `app/v1`: nombres y propiedades
284
+ * de sus eventos, capabilities, planes y meters. Con ellos `track()` o
285
+ * `capabilities.check()` fallan en compilación ante un nombre o una propiedad
286
+ * que el manifiesto no declara.
287
+ */
288
+
289
+ type JsonSchema = {
290
+ type?: string | string[];
291
+ properties?: Record<string, JsonSchema>;
292
+ required?: string[];
293
+ items?: JsonSchema;
294
+ enum?: unknown[];
295
+ additionalProperties?: boolean | JsonSchema;
296
+ };
297
+ /** Un JSON Schema (subconjunto habitual) como tipo TypeScript; lo desconocido es `unknown`. */
298
+ declare function schemaToType(schema: JsonSchema | undefined, indent?: string): string;
299
+ declare function generateAppTypes(manifest: AppManifest): string;
300
+
301
+ export { type CliIo, SyncError, type SyncOptions, type SyncResult, generateAppTypes, runCli, schemaToType, syncApp, validateManifest };
@@ -0,0 +1,301 @@
1
+ import { z } from 'zod';
2
+
3
+ type CliIo = {
4
+ cwd: string;
5
+ env: Record<string, string | undefined>;
6
+ out: (line: string) => void;
7
+ err: (line: string) => void;
8
+ fetch?: typeof fetch;
9
+ };
10
+ declare function runCli(argv: string[], io: CliIo): Promise<number>;
11
+
12
+ /**
13
+ * Manifiesto de aplicación `app/v1` — el `customy.app.json` que versiona cada
14
+ * app del ecosistema (ADR CUSTOMY_SDK_PLATFORM_DECISION_2026-09-24, D3).
15
+ *
16
+ * Declara qué productos usa la app y con qué scopes, qué recursos enlaza
17
+ * (validados contra el `product/v1` de cada producto), qué eventos emite con su
18
+ * schema y propósito de consentimiento, y sus capabilities, planes y meters.
19
+ * `customy apps sync` lo reconcilia; ningún servicio de Customy conoce apps por nombre.
20
+ */
21
+
22
+ declare const AppManifestSchema: z.ZodObject<{
23
+ /** Referencia opcional al JSON Schema publicado, para autocompletado en editores. */
24
+ $schema: z.ZodOptional<z.ZodString>;
25
+ schema: z.ZodLiteral<"app/v1">;
26
+ key: z.ZodString;
27
+ name: z.ZodString;
28
+ origins: z.ZodEffects<z.ZodObject<{
29
+ staging: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
30
+ production: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
31
+ }, "strict", z.ZodTypeAny, {
32
+ staging?: string | undefined;
33
+ production?: string | undefined;
34
+ }, {
35
+ staging?: string | undefined;
36
+ production?: string | undefined;
37
+ }>, {
38
+ staging?: string | undefined;
39
+ production?: string | undefined;
40
+ }, {
41
+ staging?: string | undefined;
42
+ production?: string | undefined;
43
+ }>;
44
+ products: z.ZodDefault<z.ZodArray<z.ZodObject<{
45
+ product: z.ZodString;
46
+ /** Scopes de producto que pedirán sus credenciales de máquina (`<producto>:<scope>`). */
47
+ scopes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
48
+ }, "strict", z.ZodTypeAny, {
49
+ product: string;
50
+ scopes: string[];
51
+ }, {
52
+ product: string;
53
+ scopes?: string[] | undefined;
54
+ }>, "many">>;
55
+ resources: z.ZodDefault<z.ZodArray<z.ZodObject<{
56
+ key: z.ZodString;
57
+ product: z.ZodString;
58
+ bindingKind: z.ZodOptional<z.ZodEnum<["product", "internal_service", "external_destination", "public_form", "private_collection", "external_source", "external_automation", "external_communication"]>>;
59
+ operations: z.ZodOptional<z.ZodArray<z.ZodEnum<["read", "propose", "submit", "read_owned", "write_owned", "research", "deliver_budget_alert", "deliver_notification"]>, "many">>;
60
+ }, "strict", z.ZodTypeAny, {
61
+ product: string;
62
+ key: string;
63
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
64
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
65
+ }, {
66
+ product: string;
67
+ key: string;
68
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
69
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
70
+ }>, "many">>;
71
+ events: z.ZodDefault<z.ZodArray<z.ZodObject<{
72
+ name: z.ZodString;
73
+ type: z.ZodEnum<["track", "identify", "group", "page", "screen", "alias"]>;
74
+ schemaVersion: z.ZodNumber;
75
+ /** JSON Schema de `properties`; se publica como schema fijado del evento. */
76
+ properties: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
77
+ purposes: z.ZodArray<z.ZodString, "many">;
78
+ }, "strict", z.ZodTypeAny, {
79
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
80
+ name: string;
81
+ schemaVersion: number;
82
+ properties: Record<string, unknown>;
83
+ purposes: string[];
84
+ }, {
85
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
86
+ name: string;
87
+ schemaVersion: number;
88
+ purposes: string[];
89
+ properties?: Record<string, unknown> | undefined;
90
+ }>, "many">>;
91
+ capabilities: z.ZodDefault<z.ZodArray<z.ZodObject<{
92
+ lookupKey: z.ZodString;
93
+ name: z.ZodString;
94
+ type: z.ZodEnum<["boolean", "metered", "config"]>;
95
+ meter: z.ZodOptional<z.ZodString>;
96
+ }, "strict", z.ZodTypeAny, {
97
+ type: "boolean" | "metered" | "config";
98
+ name: string;
99
+ lookupKey: string;
100
+ meter?: string | undefined;
101
+ }, {
102
+ type: "boolean" | "metered" | "config";
103
+ name: string;
104
+ lookupKey: string;
105
+ meter?: string | undefined;
106
+ }>, "many">>;
107
+ plans: z.ZodDefault<z.ZodArray<z.ZodObject<{
108
+ code: z.ZodString;
109
+ name: z.ZodString;
110
+ rank: z.ZodDefault<z.ZodNumber>;
111
+ capabilities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
+ }, "strict", z.ZodTypeAny, {
113
+ code: string;
114
+ name: string;
115
+ rank: number;
116
+ capabilities: Record<string, unknown>;
117
+ }, {
118
+ code: string;
119
+ name: string;
120
+ rank?: number | undefined;
121
+ capabilities?: Record<string, unknown> | undefined;
122
+ }>, "many">>;
123
+ meters: z.ZodDefault<z.ZodArray<z.ZodObject<{
124
+ code: z.ZodString;
125
+ aggregation: z.ZodEnum<["sum", "count", "last"]>;
126
+ unit: z.ZodString;
127
+ }, "strict", z.ZodTypeAny, {
128
+ code: string;
129
+ aggregation: "sum" | "count" | "last";
130
+ unit: string;
131
+ }, {
132
+ code: string;
133
+ aggregation: "sum" | "count" | "last";
134
+ unit: string;
135
+ }>, "many">>;
136
+ }, "strict", z.ZodTypeAny, {
137
+ schema: "app/v1";
138
+ key: string;
139
+ name: string;
140
+ capabilities: {
141
+ type: "boolean" | "metered" | "config";
142
+ name: string;
143
+ lookupKey: string;
144
+ meter?: string | undefined;
145
+ }[];
146
+ origins: {
147
+ staging?: string | undefined;
148
+ production?: string | undefined;
149
+ };
150
+ products: {
151
+ product: string;
152
+ scopes: string[];
153
+ }[];
154
+ resources: {
155
+ product: string;
156
+ key: string;
157
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
158
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
159
+ }[];
160
+ events: {
161
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
162
+ name: string;
163
+ schemaVersion: number;
164
+ properties: Record<string, unknown>;
165
+ purposes: string[];
166
+ }[];
167
+ plans: {
168
+ code: string;
169
+ name: string;
170
+ rank: number;
171
+ capabilities: Record<string, unknown>;
172
+ }[];
173
+ meters: {
174
+ code: string;
175
+ aggregation: "sum" | "count" | "last";
176
+ unit: string;
177
+ }[];
178
+ $schema?: string | undefined;
179
+ }, {
180
+ schema: "app/v1";
181
+ key: string;
182
+ name: string;
183
+ origins: {
184
+ staging?: string | undefined;
185
+ production?: string | undefined;
186
+ };
187
+ capabilities?: {
188
+ type: "boolean" | "metered" | "config";
189
+ name: string;
190
+ lookupKey: string;
191
+ meter?: string | undefined;
192
+ }[] | undefined;
193
+ $schema?: string | undefined;
194
+ products?: {
195
+ product: string;
196
+ scopes?: string[] | undefined;
197
+ }[] | undefined;
198
+ resources?: {
199
+ product: string;
200
+ key: string;
201
+ operations?: ("read" | "propose" | "submit" | "read_owned" | "write_owned" | "research" | "deliver_budget_alert" | "deliver_notification")[] | undefined;
202
+ bindingKind?: "product" | "internal_service" | "external_destination" | "public_form" | "private_collection" | "external_source" | "external_automation" | "external_communication" | undefined;
203
+ }[] | undefined;
204
+ events?: {
205
+ type: "track" | "identify" | "group" | "page" | "screen" | "alias";
206
+ name: string;
207
+ schemaVersion: number;
208
+ purposes: string[];
209
+ properties?: Record<string, unknown> | undefined;
210
+ }[] | undefined;
211
+ plans?: {
212
+ code: string;
213
+ name: string;
214
+ rank?: number | undefined;
215
+ capabilities?: Record<string, unknown> | undefined;
216
+ }[] | undefined;
217
+ meters?: {
218
+ code: string;
219
+ aggregation: "sum" | "count" | "last";
220
+ unit: string;
221
+ }[] | undefined;
222
+ }>;
223
+ type AppManifest = z.infer<typeof AppManifestSchema>;
224
+
225
+ /**
226
+ * `customy apps validate | sync`: reconcilia el `customy.app.json` de una app
227
+ * con Customy Access (ADR SDK, D3).
228
+ *
229
+ * `sync` es idempotente: instala la app en el Workspace si no existe (el
230
+ * install repetido devuelve la misma conexión) y, si el manifiesto cambió,
231
+ * publica una versión nueva sobre la revisión actual. Access lleva después el
232
+ * manifiesto a los productos (los `events` a Data) y devuelve cómo fue; repetir
233
+ * `sync` con el mismo manifiesto repara una reconciliación fallida. Nunca crea
234
+ * credenciales: eso lo decide un administrador del Workspace.
235
+ */
236
+
237
+ type Problem = {
238
+ path: string;
239
+ code: string;
240
+ };
241
+ declare function validateManifest(input: unknown): {
242
+ ok: true;
243
+ manifest: AppManifest;
244
+ } | {
245
+ ok: false;
246
+ problems: Problem[];
247
+ };
248
+ type SyncOptions = {
249
+ manifest: AppManifest;
250
+ accessUrl: string;
251
+ token: string;
252
+ workspaceEnvironmentId: string;
253
+ reason: string;
254
+ fetch?: typeof fetch;
255
+ };
256
+ type ProductReconciliation = {
257
+ status: "skipped";
258
+ reason: string;
259
+ } | {
260
+ status: "reconciled";
261
+ changed: boolean;
262
+ resourceId?: string;
263
+ } | {
264
+ status: "failed";
265
+ code: string;
266
+ };
267
+ type SyncResult = {
268
+ action: "installed" | "updated" | "unchanged";
269
+ applicationId: string;
270
+ environmentId: string;
271
+ revision: number;
272
+ /** Cómo quedó cada producto; vacío si Access no lo informa. */
273
+ reconciliation: Record<string, ProductReconciliation>;
274
+ };
275
+ declare class SyncError extends Error {
276
+ readonly code: string;
277
+ readonly status: number;
278
+ constructor(code: string, status: number);
279
+ }
280
+ declare function syncApp(options: SyncOptions): Promise<SyncResult>;
281
+
282
+ /**
283
+ * Tipos de una app a partir de su manifiesto `app/v1`: nombres y propiedades
284
+ * de sus eventos, capabilities, planes y meters. Con ellos `track()` o
285
+ * `capabilities.check()` fallan en compilación ante un nombre o una propiedad
286
+ * que el manifiesto no declara.
287
+ */
288
+
289
+ type JsonSchema = {
290
+ type?: string | string[];
291
+ properties?: Record<string, JsonSchema>;
292
+ required?: string[];
293
+ items?: JsonSchema;
294
+ enum?: unknown[];
295
+ additionalProperties?: boolean | JsonSchema;
296
+ };
297
+ /** Un JSON Schema (subconjunto habitual) como tipo TypeScript; lo desconocido es `unknown`. */
298
+ declare function schemaToType(schema: JsonSchema | undefined, indent?: string): string;
299
+ declare function generateAppTypes(manifest: AppManifest): string;
300
+
301
+ export { type CliIo, SyncError, type SyncOptions, type SyncResult, generateAppTypes, runCli, schemaToType, syncApp, validateManifest };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { SyncError, generateAppTypes, runCli, schemaToType, syncApp, validateManifest } from './chunk-XKJUU7AX.mjs';
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@customyai/cli",
3
+ "version": "0.1.0",
4
+ "description": "Customy CLI for apps: validate, type and sync customy.app.json (customy apps validate | codegen | sync). Also usable as a library.",
5
+ "license": "MIT",
6
+ "author": "Customy <hello@customy.ai>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/customyco/customy-js.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/customyco/customy-js/issues"
14
+ },
15
+ "keywords": [
16
+ "customy",
17
+ "cli",
18
+ "manifest",
19
+ "codegen",
20
+ "sdk"
21
+ ],
22
+ "type": "module",
23
+ "main": "./dist/index.cjs",
24
+ "module": "./dist/index.mjs",
25
+ "types": "./dist/index.d.cts",
26
+ "exports": {
27
+ ".": {
28
+ "import": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.mjs"
31
+ },
32
+ "require": {
33
+ "types": "./dist/index.d.cts",
34
+ "default": "./dist/index.cjs"
35
+ }
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "bin": {
40
+ "customy": "./dist/bin.mjs"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "README.md",
45
+ "LICENSE",
46
+ "CHANGELOG.md"
47
+ ],
48
+ "engines": {
49
+ "node": ">=20"
50
+ },
51
+ "scripts": {
52
+ "build": "rm -rf dist && tsup",
53
+ "typecheck": "tsc --noEmit",
54
+ "test": "vitest run"
55
+ },
56
+ "dependencies": {
57
+ "zod": "^3.23.8"
58
+ },
59
+ "devDependencies": {
60
+ "typescript": "^5.5.0",
61
+ "vitest": "^4.1.11",
62
+ "tsup": "^8.0.0",
63
+ "@types/node": "^20.14.2"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public",
67
+ "provenance": true
68
+ }
69
+ }