@zitadel/config 0.0.0 → 0.1.0-alpha.14
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/defaults/README-flows.md +37 -0
- package/defaults/README-schemas.md +32 -0
- package/defaults/default-human-user.json +46 -0
- package/defaults/default-login.json +131 -0
- package/dist/defaults-B2iIPSSl.mjs +201 -0
- package/dist/defaults-B2iIPSSl.mjs.map +1 -0
- package/dist/defaults-DzfOT2_7.d.mts +30 -0
- package/dist/defaults-DzfOT2_7.d.mts.map +1 -0
- package/dist/defaults.d.mts +2 -0
- package/dist/defaults.mjs +2 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +3 -0
- package/dist/schemas.d.mts +7 -0
- package/dist/schemas.d.mts.map +1 -0
- package/dist/schemas.mjs +9 -0
- package/dist/schemas.mjs.map +1 -0
- package/package.json +53 -4
- package/README.md +0 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# `.zitadel/flows/`
|
|
2
|
+
|
|
3
|
+
Flow definitions. Each JSON file describes an end-to-end journey —
|
|
4
|
+
which fields the user sees at each step, which credentials are checked,
|
|
5
|
+
and how one step transitions to the next. The Zitadel flow engine runs
|
|
6
|
+
these on the platform; the widget renders whatever the engine emits.
|
|
7
|
+
|
|
8
|
+
## What's in a flow file
|
|
9
|
+
|
|
10
|
+
- `purposes` — entry step for each purpose (`login`, `register`, …). A
|
|
11
|
+
single flow can serve multiple purposes.
|
|
12
|
+
- `steps[]` — the ordered list of screens. Each step's `fields[]`
|
|
13
|
+
references properties of the pinned schema (or reserved tokens like
|
|
14
|
+
`x-auth-methods#password`), and `transitions` wires it to the next
|
|
15
|
+
step.
|
|
16
|
+
- `user_schema` — pins the flow to one specific user-schema revision.
|
|
17
|
+
- `audience` (optional) — scopes the flow to specific apps or teams.
|
|
18
|
+
|
|
19
|
+
## What you can do
|
|
20
|
+
|
|
21
|
+
- **Add or remove a step** — extend `steps[]`.
|
|
22
|
+
- **Change which fields a step collects** — edit `steps[].fields[]`.
|
|
23
|
+
Values must be properties of the pinned schema (or reserved credential
|
|
24
|
+
tokens).
|
|
25
|
+
- **Rewire transitions** — edit `steps[].transitions` to point at a
|
|
26
|
+
different next step, or use `action: switch` / `pivot` to jump to
|
|
27
|
+
another flow.
|
|
28
|
+
- **Add another flow** — drop a new JSON file with its own `purposes`
|
|
29
|
+
and `audience` (e.g. a per-team login).
|
|
30
|
+
|
|
31
|
+
## Applying changes
|
|
32
|
+
|
|
33
|
+
`zitadel plan` previews the change; `zitadel apply` PUTs the updated
|
|
34
|
+
flow to the platform. When the pinned user-schema is edited, the flow
|
|
35
|
+
stays pinned to the old revision — `apply` prints the new revision id so
|
|
36
|
+
you can copy it into `user_schema` (and update `steps[].fields[]` for
|
|
37
|
+
any added/removed properties) when you're ready to adopt it.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# `.zitadel/schemas/`
|
|
2
|
+
|
|
3
|
+
User-schema files. Each JSON file describes one editable user type — the
|
|
4
|
+
shape of the user records the platform stores and the login/register
|
|
5
|
+
flows collect (email, name, phoneNumber, custom claims, etc.). A project
|
|
6
|
+
can hold as many schemas as you need (e.g. one for end users, one for
|
|
7
|
+
internal admins).
|
|
8
|
+
|
|
9
|
+
## What's in a schema file
|
|
10
|
+
|
|
11
|
+
- `objectType` — groups revisions of the same logical user type. Do not
|
|
12
|
+
rename it after the first `apply`; the platform correlates history by
|
|
13
|
+
this key.
|
|
14
|
+
- `properties` / `required` — the user's attributes and which of them
|
|
15
|
+
must be present on every user.
|
|
16
|
+
- `x-auth-methods` — which credentials this user type supports
|
|
17
|
+
(password, passkey, …).
|
|
18
|
+
|
|
19
|
+
## What you can do
|
|
20
|
+
|
|
21
|
+
- **Add or edit a property** — extend `properties`, mark it `required`
|
|
22
|
+
if it must be present on every user.
|
|
23
|
+
- **Enable or disable an auth method** — flip an `x-auth-methods` entry.
|
|
24
|
+
- **Add another user type** — drop a new JSON file next to this one.
|
|
25
|
+
|
|
26
|
+
## Applying changes
|
|
27
|
+
|
|
28
|
+
`zitadel plan` previews the change; `zitadel apply` publishes it. Editing
|
|
29
|
+
a schema publishes a **new immutable revision** — existing users keep
|
|
30
|
+
validating against the previous revision. Flows that reference this
|
|
31
|
+
schema stay pinned to the old revision until you re-pin them; see
|
|
32
|
+
`.zitadel/flows/README.md`.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "DefaultHumanUserSchema",
|
|
3
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
4
|
+
"metaSchema": "${SERVER_URL}/user-schema.json",
|
|
5
|
+
"$id": "${USER_SCHEMA_URL}",
|
|
6
|
+
"objectType": "human-user",
|
|
7
|
+
"kind": "user-schema",
|
|
8
|
+
"type": "object",
|
|
9
|
+
"description": "The default editable schema for human users.",
|
|
10
|
+
"x-auth-methods": {
|
|
11
|
+
"password": {
|
|
12
|
+
"enabled": true,
|
|
13
|
+
"position": 1
|
|
14
|
+
},
|
|
15
|
+
"passkey": {
|
|
16
|
+
"enabled": true,
|
|
17
|
+
"position": 2
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"required": [
|
|
21
|
+
"email"
|
|
22
|
+
],
|
|
23
|
+
"properties": {
|
|
24
|
+
"email": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"format": "email",
|
|
27
|
+
"x-unique": "project",
|
|
28
|
+
"description": "The user's email address."
|
|
29
|
+
},
|
|
30
|
+
"givenName": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"maxLength": 50,
|
|
33
|
+
"description": "The user's given (first) name."
|
|
34
|
+
},
|
|
35
|
+
"familyName": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"maxLength": 50,
|
|
38
|
+
"description": "The user's family (last) name."
|
|
39
|
+
},
|
|
40
|
+
"dateOfBirth": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"format": "date",
|
|
43
|
+
"description": "The user's date of birth (ISO 8601, YYYY-MM-DD)."
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "default-login",
|
|
3
|
+
"status": "active",
|
|
4
|
+
"user_schema": "${USER_SCHEMA_URL}",
|
|
5
|
+
"purposes": {
|
|
6
|
+
"login": "identifier",
|
|
7
|
+
"register": "register"
|
|
8
|
+
},
|
|
9
|
+
"steps": [
|
|
10
|
+
{
|
|
11
|
+
"name": "identifier",
|
|
12
|
+
"fields": [
|
|
13
|
+
"email"
|
|
14
|
+
],
|
|
15
|
+
"actions": [
|
|
16
|
+
{
|
|
17
|
+
"name": "submit",
|
|
18
|
+
"kind": "submit",
|
|
19
|
+
"primary": true,
|
|
20
|
+
"text_key": "identifier.action.continue"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "passkey",
|
|
24
|
+
"kind": "passkey",
|
|
25
|
+
"primary": false,
|
|
26
|
+
"text_key": "identifier.action.passkey"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"transitions": {
|
|
30
|
+
"submit": {
|
|
31
|
+
"target": "password"
|
|
32
|
+
},
|
|
33
|
+
"passkey": {
|
|
34
|
+
"target": "done"
|
|
35
|
+
},
|
|
36
|
+
"user_not_found": {
|
|
37
|
+
"target": "register"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "password",
|
|
43
|
+
"fields": [
|
|
44
|
+
"x-auth-methods#password"
|
|
45
|
+
],
|
|
46
|
+
"actions": [
|
|
47
|
+
{
|
|
48
|
+
"name": "submit",
|
|
49
|
+
"kind": "submit",
|
|
50
|
+
"primary": true,
|
|
51
|
+
"text_key": "password.action.signin"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "passkey",
|
|
55
|
+
"kind": "passkey",
|
|
56
|
+
"primary": false,
|
|
57
|
+
"text_key": "password.action.passkey"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"transitions": {
|
|
61
|
+
"submit": {
|
|
62
|
+
"target": "done"
|
|
63
|
+
},
|
|
64
|
+
"passkey": {
|
|
65
|
+
"target": "done"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "register",
|
|
71
|
+
"fields": [
|
|
72
|
+
"email",
|
|
73
|
+
"givenName",
|
|
74
|
+
"familyName",
|
|
75
|
+
"dateOfBirth"
|
|
76
|
+
],
|
|
77
|
+
"actions": [
|
|
78
|
+
{
|
|
79
|
+
"name": "submit",
|
|
80
|
+
"kind": "submit",
|
|
81
|
+
"primary": true,
|
|
82
|
+
"text_key": "register.action.password"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "passkey_register",
|
|
86
|
+
"kind": "passkey_register",
|
|
87
|
+
"primary": false,
|
|
88
|
+
"text_key": "register.action.passkey"
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"transitions": {
|
|
92
|
+
"submit": {
|
|
93
|
+
"target": "register-password"
|
|
94
|
+
},
|
|
95
|
+
"passkey_register": {
|
|
96
|
+
"target": "done"
|
|
97
|
+
},
|
|
98
|
+
"user_already_exists": {
|
|
99
|
+
"target": "password"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "register-password",
|
|
105
|
+
"fields": [
|
|
106
|
+
"x-auth-methods#password"
|
|
107
|
+
],
|
|
108
|
+
"actions": [
|
|
109
|
+
{
|
|
110
|
+
"name": "submit",
|
|
111
|
+
"kind": "submit",
|
|
112
|
+
"primary": true,
|
|
113
|
+
"text_key": "register-password.action.submit"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"on_success": "create_user",
|
|
117
|
+
"transitions": {
|
|
118
|
+
"submit": {
|
|
119
|
+
"target": "done"
|
|
120
|
+
},
|
|
121
|
+
"user_already_exists": {
|
|
122
|
+
"target": "password"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"name": "done",
|
|
128
|
+
"complete": "show"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
//#region defaults/default-human-user.json
|
|
4
|
+
var default_human_user_default = {
|
|
5
|
+
title: "DefaultHumanUserSchema",
|
|
6
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
7
|
+
metaSchema: "${SERVER_URL}/user-schema.json",
|
|
8
|
+
$id: "${USER_SCHEMA_URL}",
|
|
9
|
+
objectType: "human-user",
|
|
10
|
+
kind: "user-schema",
|
|
11
|
+
type: "object",
|
|
12
|
+
description: "The default editable schema for human users.",
|
|
13
|
+
"x-auth-methods": {
|
|
14
|
+
"password": {
|
|
15
|
+
"enabled": true,
|
|
16
|
+
"position": 1
|
|
17
|
+
},
|
|
18
|
+
"passkey": {
|
|
19
|
+
"enabled": true,
|
|
20
|
+
"position": 2
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
required: ["email"],
|
|
24
|
+
properties: {
|
|
25
|
+
"email": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"format": "email",
|
|
28
|
+
"x-unique": "project",
|
|
29
|
+
"description": "The user's email address."
|
|
30
|
+
},
|
|
31
|
+
"givenName": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"maxLength": 50,
|
|
34
|
+
"description": "The user's given (first) name."
|
|
35
|
+
},
|
|
36
|
+
"familyName": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"maxLength": 50,
|
|
39
|
+
"description": "The user's family (last) name."
|
|
40
|
+
},
|
|
41
|
+
"dateOfBirth": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"format": "date",
|
|
44
|
+
"description": "The user's date of birth (ISO 8601, YYYY-MM-DD)."
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region defaults/default-login.json
|
|
50
|
+
var default_login_default = {
|
|
51
|
+
name: "default-login",
|
|
52
|
+
status: "active",
|
|
53
|
+
user_schema: "${USER_SCHEMA_URL}",
|
|
54
|
+
purposes: {
|
|
55
|
+
"login": "identifier",
|
|
56
|
+
"register": "register"
|
|
57
|
+
},
|
|
58
|
+
steps: [
|
|
59
|
+
{
|
|
60
|
+
"name": "identifier",
|
|
61
|
+
"fields": ["email"],
|
|
62
|
+
"actions": [{
|
|
63
|
+
"name": "submit",
|
|
64
|
+
"kind": "submit",
|
|
65
|
+
"primary": true,
|
|
66
|
+
"text_key": "identifier.action.continue"
|
|
67
|
+
}, {
|
|
68
|
+
"name": "passkey",
|
|
69
|
+
"kind": "passkey",
|
|
70
|
+
"primary": false,
|
|
71
|
+
"text_key": "identifier.action.passkey"
|
|
72
|
+
}],
|
|
73
|
+
"transitions": {
|
|
74
|
+
"submit": { "target": "password" },
|
|
75
|
+
"passkey": { "target": "done" },
|
|
76
|
+
"user_not_found": { "target": "register" }
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "password",
|
|
81
|
+
"fields": ["x-auth-methods#password"],
|
|
82
|
+
"actions": [{
|
|
83
|
+
"name": "submit",
|
|
84
|
+
"kind": "submit",
|
|
85
|
+
"primary": true,
|
|
86
|
+
"text_key": "password.action.signin"
|
|
87
|
+
}, {
|
|
88
|
+
"name": "passkey",
|
|
89
|
+
"kind": "passkey",
|
|
90
|
+
"primary": false,
|
|
91
|
+
"text_key": "password.action.passkey"
|
|
92
|
+
}],
|
|
93
|
+
"transitions": {
|
|
94
|
+
"submit": { "target": "done" },
|
|
95
|
+
"passkey": { "target": "done" }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "register",
|
|
100
|
+
"fields": [
|
|
101
|
+
"email",
|
|
102
|
+
"givenName",
|
|
103
|
+
"familyName",
|
|
104
|
+
"dateOfBirth"
|
|
105
|
+
],
|
|
106
|
+
"actions": [{
|
|
107
|
+
"name": "submit",
|
|
108
|
+
"kind": "submit",
|
|
109
|
+
"primary": true,
|
|
110
|
+
"text_key": "register.action.password"
|
|
111
|
+
}, {
|
|
112
|
+
"name": "passkey_register",
|
|
113
|
+
"kind": "passkey_register",
|
|
114
|
+
"primary": false,
|
|
115
|
+
"text_key": "register.action.passkey"
|
|
116
|
+
}],
|
|
117
|
+
"transitions": {
|
|
118
|
+
"submit": { "target": "register-password" },
|
|
119
|
+
"passkey_register": { "target": "done" },
|
|
120
|
+
"user_already_exists": { "target": "password" }
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "register-password",
|
|
125
|
+
"fields": ["x-auth-methods#password"],
|
|
126
|
+
"actions": [{
|
|
127
|
+
"name": "submit",
|
|
128
|
+
"kind": "submit",
|
|
129
|
+
"primary": true,
|
|
130
|
+
"text_key": "register-password.action.submit"
|
|
131
|
+
}],
|
|
132
|
+
"on_success": "create_user",
|
|
133
|
+
"transitions": {
|
|
134
|
+
"submit": { "target": "done" },
|
|
135
|
+
"user_already_exists": { "target": "password" }
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "done",
|
|
140
|
+
"complete": "show"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
};
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region src/readmes.ts
|
|
146
|
+
/**
|
|
147
|
+
* README content the CLI copies to `.zitadel/schemas/README.md` during setup.
|
|
148
|
+
* Source of truth is `packages/config/defaults/README-schemas.md`; the Go
|
|
149
|
+
* server-side embed reads the same file (see `defaults.go`).
|
|
150
|
+
*/
|
|
151
|
+
function schemasReadmeContent() {
|
|
152
|
+
return readFileSync(readmeUrl("README-schemas.md"), "utf8");
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* README content the CLI copies to `.zitadel/flows/README.md` during setup.
|
|
156
|
+
* Source of truth is `packages/config/defaults/README-flows.md`.
|
|
157
|
+
*/
|
|
158
|
+
function flowsReadmeContent() {
|
|
159
|
+
return readFileSync(readmeUrl("README-flows.md"), "utf8");
|
|
160
|
+
}
|
|
161
|
+
function readmeUrl(filename) {
|
|
162
|
+
return fileURLToPath(new URL(`../defaults/${filename}`, import.meta.url));
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
//#region src/defaults.ts
|
|
166
|
+
const DEFAULT_BUILTIN_SCHEMA_BASE = "https://nextgen.com/api/schemas";
|
|
167
|
+
const DEFAULT_FLOW_SCHEMA_URI = "https://nextgen.com/flow-definition.json";
|
|
168
|
+
const DEFAULT_SCHEMA_CONFIG_PATH = ".zitadel/schemas/default-human-user.json";
|
|
169
|
+
const DEFAULT_FLOW_CONFIG_PATH = ".zitadel/flows/default-login.json";
|
|
170
|
+
function defaultHumanUserSchemaUrl(builtinSchemaBase = DEFAULT_BUILTIN_SCHEMA_BASE) {
|
|
171
|
+
return `${trimTrailingSlash(builtinSchemaBase)}/default-human-user.json`;
|
|
172
|
+
}
|
|
173
|
+
function getDefaultHumanUserSchema(options = {}) {
|
|
174
|
+
const builtinSchemaBase = trimTrailingSlash(options.builtinSchemaBase ?? "https://nextgen.com/api/schemas");
|
|
175
|
+
return renderTemplate(default_human_user_default, {
|
|
176
|
+
SERVER_URL: builtinSchemaBase,
|
|
177
|
+
USER_SCHEMA_URL: options.userSchemaUrl ?? defaultHumanUserSchemaUrl(builtinSchemaBase)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function getDefaultLoginFlow(options = {}) {
|
|
181
|
+
const builtinSchemaBase = trimTrailingSlash(options.builtinSchemaBase ?? "https://nextgen.com/api/schemas");
|
|
182
|
+
return renderTemplate(default_login_default, {
|
|
183
|
+
SERVER_URL: builtinSchemaBase,
|
|
184
|
+
USER_SCHEMA_URL: options.userSchemaUrl ?? defaultHumanUserSchemaUrl(builtinSchemaBase)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function renderTemplate(value, replacements) {
|
|
188
|
+
if (Array.isArray(value)) return value.map((item) => renderTemplate(item, replacements));
|
|
189
|
+
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, renderTemplate(item, replacements)]));
|
|
190
|
+
if (typeof value === "string") return value.replaceAll(/\$\{([A-Z_]+)\}/g, (match, name) => {
|
|
191
|
+
return replacements[name] ?? match;
|
|
192
|
+
});
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
function trimTrailingSlash(value) {
|
|
196
|
+
return value.replace(/\/+$/u, "");
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
export { defaultHumanUserSchemaUrl as a, flowsReadmeContent as c, DEFAULT_SCHEMA_CONFIG_PATH as i, schemasReadmeContent as l, DEFAULT_FLOW_CONFIG_PATH as n, getDefaultHumanUserSchema as o, DEFAULT_FLOW_SCHEMA_URI as r, getDefaultLoginFlow as s, DEFAULT_BUILTIN_SCHEMA_BASE as t };
|
|
200
|
+
|
|
201
|
+
//# sourceMappingURL=defaults-B2iIPSSl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults-B2iIPSSl.mjs","names":["defaultHumanUserSchemaTemplate","defaultLoginFlowTemplate"],"sources":["../defaults/default-human-user.json","../defaults/default-login.json","../src/readmes.ts","../src/defaults.ts"],"sourcesContent":["","","import { readFileSync } from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * README content the CLI copies to `.zitadel/schemas/README.md` during setup.\n * Source of truth is `packages/config/defaults/README-schemas.md`; the Go\n * server-side embed reads the same file (see `defaults.go`).\n */\nexport function schemasReadmeContent(): string {\n return readFileSync(readmeUrl(\"README-schemas.md\"), \"utf8\");\n}\n\n/**\n * README content the CLI copies to `.zitadel/flows/README.md` during setup.\n * Source of truth is `packages/config/defaults/README-flows.md`.\n */\nexport function flowsReadmeContent(): string {\n return readFileSync(readmeUrl(\"README-flows.md\"), \"utf8\");\n}\n\nfunction readmeUrl(filename: string): string {\n return fileURLToPath(new URL(`../defaults/${filename}`, import.meta.url));\n}\n","import type {\n CreateFlowDefinitionBodyFlowDefinition,\n CreateSchemaBody,\n} from \"@zitadel/api/generated/model\";\n\nimport defaultHumanUserSchemaTemplate from \"../defaults/default-human-user.json\" with {\n type: \"json\",\n};\nimport defaultLoginFlowTemplate from \"../defaults/default-login.json\" with {\n type: \"json\",\n};\n\nexport { flowsReadmeContent, schemasReadmeContent } from \"./readmes.js\";\n\nexport const DEFAULT_BUILTIN_SCHEMA_BASE = \"https://nextgen.com/api/schemas\";\nexport const DEFAULT_FLOW_SCHEMA_URI = \"https://nextgen.com/flow-definition.json\";\nexport const DEFAULT_SCHEMA_CONFIG_PATH = \".zitadel/schemas/default-human-user.json\";\nexport const DEFAULT_FLOW_CONFIG_PATH = \".zitadel/flows/default-login.json\";\n\nexport type DefaultConfigRenderOptions = {\n builtinSchemaBase?: string;\n userSchemaUrl?: string;\n};\n\nexport function defaultHumanUserSchemaUrl(\n builtinSchemaBase = DEFAULT_BUILTIN_SCHEMA_BASE,\n): string {\n return `${trimTrailingSlash(builtinSchemaBase)}/default-human-user.json`;\n}\n\nexport function getDefaultHumanUserSchema(\n options: DefaultConfigRenderOptions = {},\n): CreateSchemaBody {\n const builtinSchemaBase = trimTrailingSlash(\n options.builtinSchemaBase ?? DEFAULT_BUILTIN_SCHEMA_BASE,\n );\n return renderTemplate(defaultHumanUserSchemaTemplate, {\n SERVER_URL: builtinSchemaBase,\n USER_SCHEMA_URL: options.userSchemaUrl ?? defaultHumanUserSchemaUrl(builtinSchemaBase),\n }) as CreateSchemaBody;\n}\n\nexport function getDefaultLoginFlow(\n options: DefaultConfigRenderOptions = {},\n): CreateFlowDefinitionBodyFlowDefinition {\n const builtinSchemaBase = trimTrailingSlash(\n options.builtinSchemaBase ?? DEFAULT_BUILTIN_SCHEMA_BASE,\n );\n return renderTemplate(defaultLoginFlowTemplate, {\n SERVER_URL: builtinSchemaBase,\n USER_SCHEMA_URL: options.userSchemaUrl ?? defaultHumanUserSchemaUrl(builtinSchemaBase),\n }) as CreateFlowDefinitionBodyFlowDefinition;\n}\n\nfunction renderTemplate(value: unknown, replacements: Record<string, string>): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => renderTemplate(item, replacements));\n }\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [key, renderTemplate(item, replacements)]),\n );\n }\n if (typeof value === \"string\") {\n return value.replaceAll(/\\$\\{([A-Z_]+)\\}/g, (match, name: string) => {\n return replacements[name] ?? match;\n });\n }\n return value;\n}\n\nfunction trimTrailingSlash(value: string): string {\n return value.replace(/\\/+$/u, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEQA,SAAgB,uBAA+B;AAC7C,QAAO,aAAa,UAAU,oBAAoB,EAAE,OAAO;;;;;;AAO7D,SAAgB,qBAA6B;AAC3C,QAAO,aAAa,UAAU,kBAAkB,EAAE,OAAO;;AAG3D,SAAS,UAAU,UAA0B;AAC3C,QAAO,cAAc,IAAI,IAAI,eAAe,YAAY,OAAO,KAAK,IAAI,CAAC;;;;ACP3E,MAAa,8BAA8B;AAC3C,MAAa,0BAA0B;AACvC,MAAa,6BAA6B;AAC1C,MAAa,2BAA2B;AAOxC,SAAgB,0BACd,oBAAoB,6BACZ;AACR,QAAO,GAAG,kBAAkB,kBAAkB,CAAC;;AAGjD,SAAgB,0BACd,UAAsC,EAAE,EACtB;CAClB,MAAM,oBAAoB,kBACxB,QAAQ,qBAAA,kCACT;AACD,QAAO,eAAeA,4BAAgC;EACpD,YAAY;EACZ,iBAAiB,QAAQ,iBAAiB,0BAA0B,kBAAkB;EACvF,CAAC;;AAGJ,SAAgB,oBACd,UAAsC,EAAE,EACA;CACxC,MAAM,oBAAoB,kBACxB,QAAQ,qBAAA,kCACT;AACD,QAAO,eAAeC,uBAA0B;EAC9C,YAAY;EACZ,iBAAiB,QAAQ,iBAAiB,0BAA0B,kBAAkB;EACvF,CAAC;;AAGJ,SAAS,eAAe,OAAgB,cAA+C;AACrF,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,KAAK,SAAS,eAAe,MAAM,aAAa,CAAC;AAEhE,KAAI,UAAU,QAAQ,OAAO,UAAU,SACrC,QAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,eAAe,MAAM,aAAa,CAAC,CAAC,CACtF;AAEH,KAAI,OAAO,UAAU,SACnB,QAAO,MAAM,WAAW,qBAAqB,OAAO,SAAiB;AACnE,SAAO,aAAa,SAAS;GAC7B;AAEJ,QAAO;;AAGT,SAAS,kBAAkB,OAAuB;AAChD,QAAO,MAAM,QAAQ,SAAS,GAAG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CreateFlowDefinitionBodyFlowDefinition, CreateSchemaBody } from "@zitadel/api/generated/model";
|
|
2
|
+
|
|
3
|
+
//#region src/readmes.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* README content the CLI copies to `.zitadel/schemas/README.md` during setup.
|
|
6
|
+
* Source of truth is `packages/config/defaults/README-schemas.md`; the Go
|
|
7
|
+
* server-side embed reads the same file (see `defaults.go`).
|
|
8
|
+
*/
|
|
9
|
+
declare function schemasReadmeContent(): string;
|
|
10
|
+
/**
|
|
11
|
+
* README content the CLI copies to `.zitadel/flows/README.md` during setup.
|
|
12
|
+
* Source of truth is `packages/config/defaults/README-flows.md`.
|
|
13
|
+
*/
|
|
14
|
+
declare function flowsReadmeContent(): string;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/defaults.d.ts
|
|
17
|
+
declare const DEFAULT_BUILTIN_SCHEMA_BASE = "https://nextgen.com/api/schemas";
|
|
18
|
+
declare const DEFAULT_FLOW_SCHEMA_URI = "https://nextgen.com/flow-definition.json";
|
|
19
|
+
declare const DEFAULT_SCHEMA_CONFIG_PATH = ".zitadel/schemas/default-human-user.json";
|
|
20
|
+
declare const DEFAULT_FLOW_CONFIG_PATH = ".zitadel/flows/default-login.json";
|
|
21
|
+
type DefaultConfigRenderOptions = {
|
|
22
|
+
builtinSchemaBase?: string;
|
|
23
|
+
userSchemaUrl?: string;
|
|
24
|
+
};
|
|
25
|
+
declare function defaultHumanUserSchemaUrl(builtinSchemaBase?: string): string;
|
|
26
|
+
declare function getDefaultHumanUserSchema(options?: DefaultConfigRenderOptions): CreateSchemaBody;
|
|
27
|
+
declare function getDefaultLoginFlow(options?: DefaultConfigRenderOptions): CreateFlowDefinitionBodyFlowDefinition;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { DefaultConfigRenderOptions as a, getDefaultLoginFlow as c, DEFAULT_SCHEMA_CONFIG_PATH as i, flowsReadmeContent as l, DEFAULT_FLOW_CONFIG_PATH as n, defaultHumanUserSchemaUrl as o, DEFAULT_FLOW_SCHEMA_URI as r, getDefaultHumanUserSchema as s, DEFAULT_BUILTIN_SCHEMA_BASE as t, schemasReadmeContent as u };
|
|
30
|
+
//# sourceMappingURL=defaults-DzfOT2_7.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults-DzfOT2_7.d.mts","names":[],"sources":["../src/readmes.ts","../src/defaults.ts"],"mappings":";;;;;;AAQA;;iBAAgB,oBAAA,CAAA;;;AAQhB;;iBAAgB,kBAAA,CAAA;;;cCFH,2BAAA;AAAA,cACA,uBAAA;AAAA,cACA,0BAAA;AAAA,cACA,wBAAA;AAAA,KAED,0BAAA;EACV,iBAAA;EACA,aAAA;AAAA;AAAA,iBAGc,yBAAA,CACd,iBAAA;AAAA,iBAKc,yBAAA,CACd,OAAA,GAAS,0BAAA,GACR,gBAAA;AAAA,iBAUa,mBAAA,CACd,OAAA,GAAS,0BAAA,GACR,sCAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as DefaultConfigRenderOptions, c as getDefaultLoginFlow, i as DEFAULT_SCHEMA_CONFIG_PATH, l as flowsReadmeContent, n as DEFAULT_FLOW_CONFIG_PATH, o as defaultHumanUserSchemaUrl, r as DEFAULT_FLOW_SCHEMA_URI, s as getDefaultHumanUserSchema, t as DEFAULT_BUILTIN_SCHEMA_BASE, u as schemasReadmeContent } from "./defaults-DzfOT2_7.mjs";
|
|
2
|
+
export { DEFAULT_BUILTIN_SCHEMA_BASE, DEFAULT_FLOW_CONFIG_PATH, DEFAULT_FLOW_SCHEMA_URI, DEFAULT_SCHEMA_CONFIG_PATH, DefaultConfigRenderOptions, defaultHumanUserSchemaUrl, flowsReadmeContent, getDefaultHumanUserSchema, getDefaultLoginFlow, schemasReadmeContent };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as defaultHumanUserSchemaUrl, c as flowsReadmeContent, i as DEFAULT_SCHEMA_CONFIG_PATH, l as schemasReadmeContent, n as DEFAULT_FLOW_CONFIG_PATH, o as getDefaultHumanUserSchema, r as DEFAULT_FLOW_SCHEMA_URI, s as getDefaultLoginFlow, t as DEFAULT_BUILTIN_SCHEMA_BASE } from "./defaults-B2iIPSSl.mjs";
|
|
2
|
+
export { DEFAULT_BUILTIN_SCHEMA_BASE, DEFAULT_FLOW_CONFIG_PATH, DEFAULT_FLOW_SCHEMA_URI, DEFAULT_SCHEMA_CONFIG_PATH, defaultHumanUserSchemaUrl, flowsReadmeContent, getDefaultHumanUserSchema, getDefaultLoginFlow, schemasReadmeContent };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as DefaultConfigRenderOptions, c as getDefaultLoginFlow, i as DEFAULT_SCHEMA_CONFIG_PATH, l as flowsReadmeContent, n as DEFAULT_FLOW_CONFIG_PATH, o as defaultHumanUserSchemaUrl, r as DEFAULT_FLOW_SCHEMA_URI, s as getDefaultHumanUserSchema, t as DEFAULT_BUILTIN_SCHEMA_BASE, u as schemasReadmeContent } from "./defaults-DzfOT2_7.mjs";
|
|
2
|
+
import { createFlowDefinitionRequestSchema, flowConfigSchema, schemaConfigSchema } from "./schemas.mjs";
|
|
3
|
+
export { DEFAULT_BUILTIN_SCHEMA_BASE, DEFAULT_FLOW_CONFIG_PATH, DEFAULT_FLOW_SCHEMA_URI, DEFAULT_SCHEMA_CONFIG_PATH, DefaultConfigRenderOptions, createFlowDefinitionRequestSchema, defaultHumanUserSchemaUrl, flowConfigSchema, flowsReadmeContent, getDefaultHumanUserSchema, getDefaultLoginFlow, schemaConfigSchema, schemasReadmeContent };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as defaultHumanUserSchemaUrl, c as flowsReadmeContent, i as DEFAULT_SCHEMA_CONFIG_PATH, l as schemasReadmeContent, n as DEFAULT_FLOW_CONFIG_PATH, o as getDefaultHumanUserSchema, r as DEFAULT_FLOW_SCHEMA_URI, s as getDefaultLoginFlow, t as DEFAULT_BUILTIN_SCHEMA_BASE } from "./defaults-B2iIPSSl.mjs";
|
|
2
|
+
import { createFlowDefinitionRequestSchema, flowConfigSchema, schemaConfigSchema } from "./schemas.mjs";
|
|
3
|
+
export { DEFAULT_BUILTIN_SCHEMA_BASE, DEFAULT_FLOW_CONFIG_PATH, DEFAULT_FLOW_SCHEMA_URI, DEFAULT_SCHEMA_CONFIG_PATH, createFlowDefinitionRequestSchema, defaultHumanUserSchemaUrl, flowConfigSchema, flowsReadmeContent, getDefaultHumanUserSchema, getDefaultLoginFlow, schemaConfigSchema, schemasReadmeContent };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/schemas.d.ts
|
|
2
|
+
declare const schemaConfigSchema: any;
|
|
3
|
+
declare const flowConfigSchema: any;
|
|
4
|
+
declare const createFlowDefinitionRequestSchema: any;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createFlowDefinitionRequestSchema, flowConfigSchema, schemaConfigSchema };
|
|
7
|
+
//# sourceMappingURL=schemas.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.mts","names":[],"sources":["../src/schemas.ts"],"mappings":";cAKa,kBAAA;AAAA,cACA,gBAAA;AAAA,cACA,iCAAA"}
|
package/dist/schemas.mjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CreateFlowDefinitionBody, CreateSchemaBody } from "@zitadel/api/generated/endpoints/zitadelNextGen.zod";
|
|
2
|
+
//#region src/schemas.ts
|
|
3
|
+
const schemaConfigSchema = CreateSchemaBody;
|
|
4
|
+
const flowConfigSchema = CreateFlowDefinitionBody.shape.flow_definition;
|
|
5
|
+
const createFlowDefinitionRequestSchema = CreateFlowDefinitionBody;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createFlowDefinitionRequestSchema, flowConfigSchema, schemaConfigSchema };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=schemas.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.mjs","names":[],"sources":["../src/schemas.ts"],"sourcesContent":["import {\n CreateFlowDefinitionBody,\n CreateSchemaBody,\n} from \"@zitadel/api/generated/endpoints/zitadelNextGen.zod\";\n\nexport const schemaConfigSchema = CreateSchemaBody;\nexport const flowConfigSchema = CreateFlowDefinitionBody.shape.flow_definition;\nexport const createFlowDefinitionRequestSchema = CreateFlowDefinitionBody;\n"],"mappings":";;AAKA,MAAa,qBAAqB;AAClC,MAAa,mBAAmB,yBAAyB,MAAM;AAC/D,MAAa,oCAAoC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zitadel/config",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-alpha.14",
|
|
4
|
+
"description": "Versioned Zitadel local config schemas and defaults",
|
|
5
|
+
"homepage": "https://github.com/zitadel/nextgen/tree/main/packages/config#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/zitadel/nextgen/issues"
|
|
8
|
+
},
|
|
5
9
|
"license": "MIT",
|
|
6
|
-
"
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/zitadel/nextgen.git",
|
|
13
|
+
"directory": "packages/config"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"defaults/*.json",
|
|
18
|
+
"defaults/*.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"@zitadel/source": "./src/index.ts",
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"import": "./dist/index.mjs"
|
|
27
|
+
},
|
|
28
|
+
"./defaults": {
|
|
29
|
+
"@zitadel/source": "./src/defaults.ts",
|
|
30
|
+
"types": "./dist/defaults.d.mts",
|
|
31
|
+
"import": "./dist/defaults.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./schemas": {
|
|
34
|
+
"@zitadel/source": "./src/schemas.ts",
|
|
35
|
+
"types": "./dist/schemas.d.mts",
|
|
36
|
+
"import": "./dist/schemas.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./defaults/default-human-user.json": "./defaults/default-human-user.json",
|
|
39
|
+
"./defaults/default-login.json": "./defaults/default-login.json",
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
7
42
|
"publishConfig": {
|
|
8
43
|
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@zitadel/api": "0.1.0-alpha.14"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"tsdown": "^0.21.10",
|
|
50
|
+
"tslib": "^2.8.1",
|
|
51
|
+
"vitest": "^4.1.7"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsdown",
|
|
55
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
56
|
+
"test": "vitest run --passWithNoTests",
|
|
57
|
+
"lint": "oxlint ."
|
|
9
58
|
}
|
|
10
|
-
}
|
|
59
|
+
}
|
package/README.md
DELETED