@customyai/cli 0.5.0 → 0.7.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.
- package/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/dist/bin.cjs +2 -2
- package/dist/bin.mjs +1 -1
- package/dist/{chunk-F676NQIB.cjs → chunk-6KGKN5HN.cjs} +28 -2
- package/dist/{chunk-AMP5DKW4.mjs → chunk-KDUW3KTG.mjs} +28 -2
- package/dist/index.cjs +11 -11
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @customyai/cli
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Environment discovery without hand-written ids: `createCustomy` resolves the Access URL, the Workspace environment and the project from `CUSTOMY_ACCESS_URL` (falls back to `CUSTOMY_ISSUER`), `CUSTOMY_WORKSPACE_ENVIRONMENT_ID` and `CUSTOMY_PROJECT_ID` (explicit option, then variable, then what `discoverApplication` found), `issuer` is now optional, and `customy.apps` fills `organizationId`, `projectId` and `accessEnvironmentId` the same way. `readCustomyEnvironment` is exported. Typed capability values: `customy apps codegen` also writes `CustomyCapabilityValues` (and `capabilityValues` in `CustomyAppTypes`), and `typedCapability` narrows the `value` of a check; existing code keeps compiling. `createFakeAccess` simulates sessions (`sessions.create/get/revoke`) and discovery (`application()`, `environment()`).
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Typed roles and permissions from the manifest: `customy apps codegen` also writes `CustomyPermission`, `CustomyRole`, `CUSTOMY_ROLE_PERMISSIONS` and `CustomyAppTypes` (and `CustomyEventProperties` is now a type alias so it satisfies the event map); `createAccess<Capability, Role, Permission>()` types `permissions.effective`, `appRoles.*`, `me()` and `AccessMeSnapshot<Role, Permission>`; `createCustomy<CustomyAppTypes>()` carries `roles` and `permissions` into `customy.access`. A misspelled role or permission fails to compile.
|
|
14
|
+
|
|
15
|
+
## 0.5.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Dependencias actualizadas:
|
|
20
|
+
- @customyai/provisioning@0.1.1
|
|
21
|
+
|
|
3
22
|
## 0.5.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ CUSTOMY_ACCESS_URL=https://access-api.customy.ai CUSTOMY_ACCESS_TOKEN=… \
|
|
|
13
13
|
|
|
14
14
|
- **validate**: sale 1 y enseña cada problema con su ruta (`plans.0.capabilities.missing: CAPABILITY_UNDECLARED`) e imprime cuántos eventos, capabilities, permisos y roles declara.
|
|
15
15
|
- **permisos y roles** (opcionales): `permissions: [{ key, description }]` y `roles: [{ key, name, description?, permissions }]`. Las claves van en el espacio de nombres de la app (`<clave>.…`, en minúsculas y sin comodines), todo permiso de un rol debe estar declarado en `permissions[]` y hay topes (128 permisos, 32 roles, 128 permisos por rol). Para que la app asigne esos roles a sus miembros, pide los scopes `app-roles:read` / `app-roles:write` en el producto `customy-access`. Los errores salen como `permissions.0.key: PERMISSION_NAMESPACE_VIOLATION`, `roles.0.permissions.1: PERMISSION_UNDECLARED`.
|
|
16
|
-
- **codegen**: escribe los tipos de la app — `CustomyEventName`, `CustomyEventProperties` (de los JSON Schema de sus eventos), `CustomyCapability`, `CustomyPlan`, `CustomyMeter` y los propósitos por evento — para `createCustomy
|
|
16
|
+
- **codegen**: escribe los tipos de la app — `CustomyEventName`, `CustomyEventProperties` (de los JSON Schema de sus eventos), `CustomyCapability`, `CustomyPlan`, `CustomyMeter`, `CustomyPermission` y `CustomyRole` (de `permissions[]` y `roles[]`), `CUSTOMY_ROLE_PERMISSIONS` (lo que da cada rol), `CustomyAppTypes` (todos juntos) y los propósitos por evento — para `createCustomy<CustomyAppTypes>()` y `createAccess<CustomyCapability, CustomyRole, CustomyPermission>()` de `@customyai/sdk` (con ellos `permissions.effective`, `appRoles.assignments.assign` y `me()` salen tipados y un nombre de rol mal escrito no compila), `createData<CustomyEventProperties>()` y `createBilling<CustomyMeter>()`.
|
|
17
17
|
- **sync**: idempotente. Instala la app en el Workspace si no existe y publica una versión nueva del manifiesto sobre la revisión actual; Access lo lleva a cada producto y la CLI enseña cómo quedó cada uno (sale 1 si alguno falló; repetir `sync` lo repara). Si el manifiesto declara permisos o roles, enseña también cuántos quedaron reconciliados (y los huérfanos). Lee `CUSTOMY_ACCESS_URL` y `CUSTOMY_ACCESS_TOKEN` (el de un administrador del Workspace) del entorno, nunca de la línea de comandos, y nunca crea credenciales.
|
|
18
18
|
|
|
19
19
|
## Provisioning de usuarios de PRUEBA
|
package/dist/bin.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk6KGKN5HN_cjs = require('./chunk-6KGKN5HN.cjs');
|
|
5
5
|
var promises = require('readline/promises');
|
|
6
6
|
|
|
7
7
|
async function prompt(question) {
|
|
@@ -12,7 +12,7 @@ async function prompt(question) {
|
|
|
12
12
|
rl.close();
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
chunk6KGKN5HN_cjs.runCli(process.argv.slice(2), {
|
|
16
16
|
cwd: process.cwd(),
|
|
17
17
|
env: process.env,
|
|
18
18
|
out: (line) => console.log(line),
|
package/dist/bin.mjs
CHANGED
|
@@ -44,20 +44,46 @@ ${indent}}` : "Record<string, never>";
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
function generateAppTypes(manifest) {
|
|
47
|
+
const roles = manifest.roles ?? [];
|
|
48
|
+
const permissions = (manifest.permissions ?? []).map((permission) => permission.key);
|
|
47
49
|
const events = manifest.events.map((event) => ` ${literal(event.name)}: ${schemaToType(event.properties, " ")};`);
|
|
48
50
|
return [
|
|
49
51
|
`// Generado por \`customy apps codegen\` desde customy.app.json (${manifest.key}). No editar a mano.`,
|
|
50
52
|
"",
|
|
51
53
|
`export type CustomyEventName = ${union(manifest.events.map((event) => event.name))};`,
|
|
52
54
|
"",
|
|
53
|
-
"export
|
|
55
|
+
"export type CustomyEventProperties = {",
|
|
54
56
|
...events,
|
|
55
|
-
"}",
|
|
57
|
+
"};",
|
|
56
58
|
"",
|
|
57
59
|
`export type CustomyCapability = ${union(manifest.capabilities.map((capability) => capability.lookupKey))};`,
|
|
60
|
+
"",
|
|
61
|
+
"/** Valor que devuelve cada capability: `boolean`, `number` (medida) o `unknown` (configuraci\xF3n). */",
|
|
62
|
+
`export type CustomyCapabilityValues = {
|
|
63
|
+
${manifest.capabilities.map((capability) => ` ${literal(capability.lookupKey)}: ${capability.type === "boolean" ? "boolean" : capability.type === "metered" ? "number" : "unknown"};`).join("\n")}
|
|
64
|
+
};`,
|
|
58
65
|
`export type CustomyPlan = ${union(manifest.plans.map((plan2) => plan2.code))};`,
|
|
59
66
|
`export type CustomyMeter = ${union(manifest.meters.map((meter) => meter.code))};`,
|
|
60
67
|
"",
|
|
68
|
+
"/** Permisos y roles del manifiesto (`permissions[]`, `roles[]`): la app pregunta por permisos y nunca escribe un nombre de rol. */",
|
|
69
|
+
`export type CustomyPermission = ${union(permissions)};`,
|
|
70
|
+
`export type CustomyRole = ${union(roles.map((role) => role.key))};`,
|
|
71
|
+
"",
|
|
72
|
+
"/** Lo que da cada rol, tal como lo declara el manifiesto. */",
|
|
73
|
+
`export const CUSTOMY_ROLE_PERMISSIONS = {
|
|
74
|
+
${roles.map((role) => ` ${literal(role.key)}: ${literal(role.permissions)},`).join("\n")}
|
|
75
|
+
} as const satisfies Record<CustomyRole, readonly CustomyPermission[]>;`,
|
|
76
|
+
"",
|
|
77
|
+
"/** Los tipos de la app juntos: `createCustomy<CustomyAppTypes>()`, `createAccess<CustomyCapability, CustomyRole, CustomyPermission>()`. */",
|
|
78
|
+
"export type CustomyAppTypes = {",
|
|
79
|
+
" events: CustomyEventProperties;",
|
|
80
|
+
" meters: CustomyMeter;",
|
|
81
|
+
" capabilities: CustomyCapability;",
|
|
82
|
+
" capabilityValues: CustomyCapabilityValues;",
|
|
83
|
+
" roles: CustomyRole;",
|
|
84
|
+
" permissions: CustomyPermission;",
|
|
85
|
+
"};",
|
|
86
|
+
"",
|
|
61
87
|
"/** Prop\xF3sitos de consentimiento que exige cada evento. */",
|
|
62
88
|
`export const CUSTOMY_EVENT_PURPOSES = {
|
|
63
89
|
${manifest.events.map((event) => ` ${literal(event.name)}: ${literal(event.purposes)},`).join("\n")}
|
|
@@ -38,20 +38,46 @@ ${indent}}` : "Record<string, never>";
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
function generateAppTypes(manifest) {
|
|
41
|
+
const roles = manifest.roles ?? [];
|
|
42
|
+
const permissions = (manifest.permissions ?? []).map((permission) => permission.key);
|
|
41
43
|
const events = manifest.events.map((event) => ` ${literal(event.name)}: ${schemaToType(event.properties, " ")};`);
|
|
42
44
|
return [
|
|
43
45
|
`// Generado por \`customy apps codegen\` desde customy.app.json (${manifest.key}). No editar a mano.`,
|
|
44
46
|
"",
|
|
45
47
|
`export type CustomyEventName = ${union(manifest.events.map((event) => event.name))};`,
|
|
46
48
|
"",
|
|
47
|
-
"export
|
|
49
|
+
"export type CustomyEventProperties = {",
|
|
48
50
|
...events,
|
|
49
|
-
"}",
|
|
51
|
+
"};",
|
|
50
52
|
"",
|
|
51
53
|
`export type CustomyCapability = ${union(manifest.capabilities.map((capability) => capability.lookupKey))};`,
|
|
54
|
+
"",
|
|
55
|
+
"/** Valor que devuelve cada capability: `boolean`, `number` (medida) o `unknown` (configuraci\xF3n). */",
|
|
56
|
+
`export type CustomyCapabilityValues = {
|
|
57
|
+
${manifest.capabilities.map((capability) => ` ${literal(capability.lookupKey)}: ${capability.type === "boolean" ? "boolean" : capability.type === "metered" ? "number" : "unknown"};`).join("\n")}
|
|
58
|
+
};`,
|
|
52
59
|
`export type CustomyPlan = ${union(manifest.plans.map((plan2) => plan2.code))};`,
|
|
53
60
|
`export type CustomyMeter = ${union(manifest.meters.map((meter) => meter.code))};`,
|
|
54
61
|
"",
|
|
62
|
+
"/** Permisos y roles del manifiesto (`permissions[]`, `roles[]`): la app pregunta por permisos y nunca escribe un nombre de rol. */",
|
|
63
|
+
`export type CustomyPermission = ${union(permissions)};`,
|
|
64
|
+
`export type CustomyRole = ${union(roles.map((role) => role.key))};`,
|
|
65
|
+
"",
|
|
66
|
+
"/** Lo que da cada rol, tal como lo declara el manifiesto. */",
|
|
67
|
+
`export const CUSTOMY_ROLE_PERMISSIONS = {
|
|
68
|
+
${roles.map((role) => ` ${literal(role.key)}: ${literal(role.permissions)},`).join("\n")}
|
|
69
|
+
} as const satisfies Record<CustomyRole, readonly CustomyPermission[]>;`,
|
|
70
|
+
"",
|
|
71
|
+
"/** Los tipos de la app juntos: `createCustomy<CustomyAppTypes>()`, `createAccess<CustomyCapability, CustomyRole, CustomyPermission>()`. */",
|
|
72
|
+
"export type CustomyAppTypes = {",
|
|
73
|
+
" events: CustomyEventProperties;",
|
|
74
|
+
" meters: CustomyMeter;",
|
|
75
|
+
" capabilities: CustomyCapability;",
|
|
76
|
+
" capabilityValues: CustomyCapabilityValues;",
|
|
77
|
+
" roles: CustomyRole;",
|
|
78
|
+
" permissions: CustomyPermission;",
|
|
79
|
+
"};",
|
|
80
|
+
"",
|
|
55
81
|
"/** Prop\xF3sitos de consentimiento que exige cada evento. */",
|
|
56
82
|
`export const CUSTOMY_EVENT_PURPOSES = {
|
|
57
83
|
${manifest.events.map((event) => ` ${literal(event.name)}: ${literal(event.purposes)},`).join("\n")}
|
package/dist/index.cjs
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk6KGKN5HN_cjs = require('./chunk-6KGKN5HN.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "EXPERIMENTS_EXIT_CODES", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunk6KGKN5HN_cjs.EXPERIMENTS_EXIT; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "PROVISIONING_EXIT_CODES", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunk6KGKN5HN_cjs.EXIT; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "SyncError", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunk6KGKN5HN_cjs.SyncError; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "generateAppTypes", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunk6KGKN5HN_cjs.generateAppTypes; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "runCli", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunk6KGKN5HN_cjs.runCli; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "runExperimentsCli", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunk6KGKN5HN_cjs.runExperimentsCli; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "runProvisioningCli", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunk6KGKN5HN_cjs.runProvisioningCli; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "schemaToType", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunk6KGKN5HN_cjs.schemaToType; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "syncApp", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunk6KGKN5HN_cjs.syncApp; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "validateManifest", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunk6KGKN5HN_cjs.validateManifest; }
|
|
46
46
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { EXPERIMENTS_EXIT as EXPERIMENTS_EXIT_CODES, EXIT as PROVISIONING_EXIT_CODES, SyncError, generateAppTypes, runCli, runExperimentsCli, runProvisioningCli, schemaToType, syncApp, validateManifest } from './chunk-
|
|
1
|
+
export { EXPERIMENTS_EXIT as EXPERIMENTS_EXIT_CODES, EXIT as PROVISIONING_EXIT_CODES, SyncError, generateAppTypes, runCli, runExperimentsCli, runProvisioningCli, schemaToType, syncApp, validateManifest } from './chunk-KDUW3KTG.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@customyai/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Customy CLI: validate, type and sync customy.app.json (customy apps ...) and provision TEST users (customy users | audit | policy | whoami). Also usable as a library.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Customy <hello@customy.ai>",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"test": "vitest run"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@customyai/provisioning": "^0.1.
|
|
59
|
+
"@customyai/provisioning": "^0.1.1",
|
|
60
60
|
"zod": "^3.23.8"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
},
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public",
|
|
70
|
-
"provenance":
|
|
70
|
+
"provenance": false
|
|
71
71
|
}
|
|
72
72
|
}
|