@agentic-kit/db-tools 0.12.47 → 0.13.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/README.md +18 -4
- package/access/findings.d.ts +93 -0
- package/access/findings.js +434 -0
- package/access/index.d.ts +5 -0
- package/access/index.js +27 -0
- package/access/policies.d.ts +142 -0
- package/access/policies.js +338 -0
- package/access/provisioning.d.ts +121 -0
- package/access/provisioning.js +381 -0
- package/access/rule-check.d.ts +52 -0
- package/access/rule-check.js +307 -0
- package/access/words.d.ts +38 -0
- package/access/words.js +530 -0
- package/app-workspace.d.ts +1 -0
- package/app-workspace.js +7 -9
- package/blueprint/blueprint-defaults.d.ts +9 -0
- package/blueprint/blueprint-defaults.js +77 -0
- package/blueprint/blueprint-schema.d.ts +68 -0
- package/blueprint/blueprint-schema.js +139 -0
- package/blueprint/field-type.d.ts +4 -0
- package/blueprint/field-type.js +100 -0
- package/blueprint/internal-policies.d.ts +1 -0
- package/blueprint/internal-policies.js +10 -0
- package/blueprint-construction.d.ts +10 -6
- package/blueprint-construction.js +34 -25
- package/context.d.ts +15 -0
- package/context.js +132 -69
- package/db-probe.d.ts +1 -1
- package/db-probe.js +19 -4
- package/esm/access/findings.d.ts +93 -0
- package/esm/access/findings.js +428 -0
- package/esm/access/index.d.ts +5 -0
- package/esm/access/index.js +5 -0
- package/esm/access/policies.d.ts +142 -0
- package/esm/access/policies.js +315 -0
- package/esm/access/provisioning.d.ts +121 -0
- package/esm/access/provisioning.js +375 -0
- package/esm/access/rule-check.d.ts +52 -0
- package/esm/access/rule-check.js +297 -0
- package/esm/access/words.d.ts +38 -0
- package/esm/access/words.js +524 -0
- package/esm/app-workspace.d.ts +1 -0
- package/esm/app-workspace.js +7 -10
- package/esm/blueprint/blueprint-defaults.d.ts +9 -0
- package/esm/blueprint/blueprint-defaults.js +74 -0
- package/esm/blueprint/blueprint-schema.d.ts +68 -0
- package/esm/blueprint/blueprint-schema.js +134 -0
- package/esm/blueprint/field-type.d.ts +4 -0
- package/esm/blueprint/field-type.js +95 -0
- package/esm/blueprint/internal-policies.d.ts +1 -0
- package/esm/blueprint/internal-policies.js +7 -0
- package/esm/blueprint-construction.d.ts +10 -6
- package/esm/blueprint-construction.js +32 -24
- package/esm/context.d.ts +15 -0
- package/esm/context.js +133 -70
- package/esm/db-probe.d.ts +1 -1
- package/esm/db-probe.js +21 -6
- package/esm/failure.d.ts +89 -0
- package/esm/failure.js +362 -0
- package/esm/gate.d.ts +6 -4
- package/esm/gate.js +42 -14
- package/esm/graphql-http.d.ts +27 -6
- package/esm/graphql-http.js +96 -24
- package/esm/host.d.ts +33 -8
- package/esm/host.js +42 -2
- package/esm/index.d.ts +22 -12
- package/esm/index.js +21 -39
- package/esm/provision-database/env-file.d.ts +7 -0
- package/esm/provision-database/env-file.js +30 -0
- package/esm/provision-database/preset-match.js +1 -2
- package/esm/provision-database/provision.d.ts +21 -4
- package/esm/provision-database/provision.js +330 -85
- package/esm/provision-database/request-database.d.ts +22 -3
- package/esm/provision-database/request-database.js +46 -13
- package/esm/ready.d.ts +20 -0
- package/esm/ready.js +45 -0
- package/esm/run-codegen/barrels.js +1 -1
- package/esm/run-codegen/endpoints.js +5 -6
- package/esm/schema-model/normalize.js +1 -1
- package/esm/schema-model.js +4 -5
- package/esm/schema-resolve.d.ts +50 -0
- package/esm/schema-resolve.js +200 -14
- package/esm/table-access.d.ts +116 -0
- package/esm/table-access.js +418 -0
- package/esm/tools/access.d.ts +218 -0
- package/esm/tools/access.js +651 -0
- package/esm/tools/add-policies.d.ts +44 -12
- package/esm/tools/add-policies.js +84 -84
- package/esm/tools/add-records.d.ts +23 -2
- package/esm/tools/add-records.js +113 -75
- package/esm/tools/add-relation-schema.d.ts +5 -5
- package/esm/tools/add-relation-schema.js +13 -14
- package/esm/tools/add-relation.d.ts +11 -2
- package/esm/tools/add-relation.js +68 -31
- package/esm/tools/create-api-key.d.ts +18 -4
- package/esm/tools/create-api-key.js +105 -54
- package/esm/tools/describe-schema.d.ts +5 -7
- package/esm/tools/describe-schema.js +41 -118
- package/esm/tools/entity-types.d.ts +54 -0
- package/esm/tools/entity-types.js +233 -0
- package/esm/tools/index.d.ts +26 -0
- package/esm/tools/index.js +151 -0
- package/esm/tools/mutations.d.ts +36 -7
- package/esm/tools/mutations.js +245 -99
- package/esm/tools/provision-blueprint.d.ts +25 -1
- package/esm/tools/provision-blueprint.js +184 -42
- package/esm/tools/provision-database.d.ts +7 -5
- package/esm/tools/provision-database.js +31 -17
- package/esm/tools/run-codegen.d.ts +27 -4
- package/esm/tools/run-codegen.js +143 -76
- package/esm/tools/templates.d.ts +30 -7
- package/esm/tools/templates.js +166 -95
- package/failure.d.ts +89 -0
- package/failure.js +375 -0
- package/gate.d.ts +6 -4
- package/gate.js +41 -13
- package/graphql-http.d.ts +27 -6
- package/graphql-http.js +105 -25
- package/host.d.ts +33 -8
- package/host.js +45 -2
- package/index.d.ts +22 -12
- package/index.js +86 -43
- package/package.json +6 -5
- package/provision-database/env-file.d.ts +7 -0
- package/provision-database/env-file.js +32 -1
- package/provision-database/preset-match.js +1 -2
- package/provision-database/provision.d.ts +21 -4
- package/provision-database/provision.js +327 -81
- package/provision-database/request-database.d.ts +22 -3
- package/provision-database/request-database.js +49 -14
- package/ready.d.ts +20 -0
- package/ready.js +52 -0
- package/run-codegen/barrels.js +1 -1
- package/run-codegen/endpoints.js +5 -6
- package/schema-model/normalize.js +4 -4
- package/schema-model.js +4 -5
- package/schema-resolve.d.ts +50 -0
- package/schema-resolve.js +209 -14
- package/table-access.d.ts +116 -0
- package/table-access.js +437 -0
- package/tools/access.d.ts +218 -0
- package/tools/access.js +669 -0
- package/tools/add-policies.d.ts +44 -12
- package/tools/add-policies.js +86 -84
- package/tools/add-records.d.ts +23 -2
- package/tools/add-records.js +113 -74
- package/tools/add-relation-schema.d.ts +5 -5
- package/tools/add-relation-schema.js +13 -14
- package/tools/add-relation.d.ts +11 -2
- package/tools/add-relation.js +69 -31
- package/tools/create-api-key.d.ts +18 -4
- package/tools/create-api-key.js +104 -53
- package/tools/describe-schema.d.ts +5 -7
- package/tools/describe-schema.js +40 -117
- package/tools/entity-types.d.ts +54 -0
- package/tools/entity-types.js +240 -0
- package/tools/index.d.ts +26 -0
- package/tools/index.js +154 -0
- package/tools/mutations.d.ts +36 -7
- package/tools/mutations.js +252 -101
- package/tools/provision-blueprint.d.ts +25 -1
- package/tools/provision-blueprint.js +186 -43
- package/tools/provision-database.d.ts +7 -5
- package/tools/provision-database.js +33 -18
- package/tools/run-codegen.d.ts +27 -4
- package/tools/run-codegen.js +141 -73
- package/tools/templates.d.ts +30 -7
- package/tools/templates.js +167 -94
- package/esm/policy/add-policies-to-table.d.ts +0 -26
- package/esm/policy/add-policies-to-table.js +0 -66
- package/esm/policy/provision-helpers.d.ts +0 -38
- package/esm/policy/provision-helpers.js +0 -50
- package/esm/tools/manage-entity-types.d.ts +0 -40
- package/esm/tools/manage-entity-types.js +0 -201
- package/policy/add-policies-to-table.d.ts +0 -26
- package/policy/add-policies-to-table.js +0 -71
- package/policy/provision-helpers.d.ts +0 -38
- package/policy/provision-helpers.js +0 -58
- package/tools/manage-entity-types.d.ts +0 -40
- package/tools/manage-entity-types.js +0 -206
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
// One plain sentence for one stored rule: the node's template filled from the rule's data (registry defaults apply),
|
|
2
|
+
// each clause whose key has a value, one sentence for each key the words do not describe, and one for each shape the
|
|
3
|
+
// backend may build into another check than the words say. A nested Authz node or AND/OR/NOT part is explained in turn,
|
|
4
|
+
// and a part no Authz node describes is said by where it sits.
|
|
5
|
+
import { APP_MEMBERSHIP_TYPE, AUTHZ_NODES, defaultsOf, derivedKeys, effectivePolicy, isObject } from './policies';
|
|
6
|
+
import { READ_BUT_NOT_SUPPORTED, unsupportedShapes } from './rule-check';
|
|
7
|
+
/** The lookup a rule check and the words read another table's columns with. */
|
|
8
|
+
export const columnsOf = (related) => (table) => related?.[String(table.id)] ?? related?.[String(table.name)];
|
|
9
|
+
// A given entity_type replaces any membership_type beside it.
|
|
10
|
+
const ENTITY_TYPE_CLAUSE = { when: 'entity_type', covers: ['membership_type'], text: 'The team is of the {entity_type} kind.' };
|
|
11
|
+
const MEMBERSHIP_TYPE_CLAUSE = { when: 'membership_type', unless: ['entity_type'], text: 'The team is {membership_type}.' };
|
|
12
|
+
const MEMBERSHIP_TYPE_WORDS = {
|
|
13
|
+
membership_type: {
|
|
14
|
+
2: 'an organization (each person also has one of their own)',
|
|
15
|
+
'*': 'a custom kind of group (number {value})'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
// The member list an app rule reads: the app's own unless the stored rule names another.
|
|
19
|
+
const APP_MEMBER_LIST = {
|
|
20
|
+
values: {
|
|
21
|
+
membership_type: {
|
|
22
|
+
[APP_MEMBERSHIP_TYPE]: 'the app',
|
|
23
|
+
2: 'any organization (each person also has one of their own)',
|
|
24
|
+
'*': 'any group of a custom kind (number {value})'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
assumes: { membership_type: APP_MEMBERSHIP_TYPE }
|
|
28
|
+
};
|
|
29
|
+
const CAPABILITIES_CLAUSE = {
|
|
30
|
+
when: 'capabilities',
|
|
31
|
+
text: 'The member must also hold these capabilities: {capabilities}. Owners and admins hold every capability, ' +
|
|
32
|
+
'and without a capabilities module for this membership only admins pass.'
|
|
33
|
+
};
|
|
34
|
+
const LEVELS_CLAUSE = {
|
|
35
|
+
when: 'levels',
|
|
36
|
+
text: 'The member must also hold these trust levels: {levels}. Owners and admins hold every level, ' +
|
|
37
|
+
'and without a capabilities module for this membership only admins pass.'
|
|
38
|
+
};
|
|
39
|
+
// The builder ORs the two flags, and an owner always carries the admin flag, so both together mean "admins".
|
|
40
|
+
const IS_ADMIN_CLAUSE = { when: 'is_admin', covers: ['is_owner'], text: 'Only admins pass; owners are admins too.' };
|
|
41
|
+
const IS_OWNER_CLAUSE = { when: 'is_owner', unless: ['is_admin'], text: 'Only owners pass.' };
|
|
42
|
+
const OBJ_TABLE_CLAUSE = { when: 'obj_table', covers: ['obj_table_id'], text: 'The related row is in the {obj_table} table.' };
|
|
43
|
+
const OBJ_TABLE_ID_CLAUSE = { when: 'obj_table_id', unless: ['obj_table'], text: 'The related table is the one with id {obj_table_id}.' };
|
|
44
|
+
const OBJ_SCHEMA_CLAUSE = { when: 'obj_schema', text: 'The related table is in the {obj_schema} schema.' };
|
|
45
|
+
const MASK_COLUMN_CLAUSE = {
|
|
46
|
+
when: 'mask_column',
|
|
47
|
+
text: 'The member must also hold every capability the row lists in its {mask_column} column; owners and admins hold them all, and a row that lists none needs nothing more.'
|
|
48
|
+
};
|
|
49
|
+
// The member list a rule names itself, read as given when the rule names no team kind.
|
|
50
|
+
const MEMBER_LIST_CLAUSE = { when: 'sprt_table', unless: ['membership_type', 'entity_type'], covers: ['sprt_schema'], text: 'The members are read from the table {sprt_table}.' };
|
|
51
|
+
// A capability list is stored as a bit mask, which cannot be read back into names without the database's capability table.
|
|
52
|
+
const MASK_CLAUSE = {
|
|
53
|
+
when: 'mask',
|
|
54
|
+
text: 'The member must also hold the capabilities in a stored capability mask; owners and admins hold them all, and these words cannot name them.'
|
|
55
|
+
};
|
|
56
|
+
// The platform's own related policies select the related row (sel_obj, sel_field id); without sel_obj the team id is
|
|
57
|
+
// selected from the member list.
|
|
58
|
+
const SEL_OBJ_CLAUSE = { when: 'sel_obj', covers: ['sel_field'], text: 'The row\'s {entity_field} column holds the related row\'s {sel_field}.' };
|
|
59
|
+
const NO_SEL_OBJ_CLAUSE = {
|
|
60
|
+
when: 'entity_field',
|
|
61
|
+
unless: ['sel_obj'],
|
|
62
|
+
text: 'Without sel_obj, the backend compares the row\'s {entity_field} column with the team id itself, not with a related row.'
|
|
63
|
+
};
|
|
64
|
+
export const POLICY_WORDS = {
|
|
65
|
+
AuthzAllowAll: { text: 'Anyone who can use the table, for every row.' },
|
|
66
|
+
AuthzAppMemberOwner: {
|
|
67
|
+
text: 'The person whose id is in the row\'s {owner_field} column, while they are an active member of {membership_type}.',
|
|
68
|
+
clauses: [CAPABILITIES_CLAUSE, LEVELS_CLAUSE, MASK_COLUMN_CLAUSE, MASK_CLAUSE, IS_ADMIN_CLAUSE, IS_OWNER_CLAUSE],
|
|
69
|
+
...APP_MEMBER_LIST
|
|
70
|
+
},
|
|
71
|
+
AuthzAppMembership: {
|
|
72
|
+
text: 'Any active member of {membership_type}, for every row.',
|
|
73
|
+
clauses: [CAPABILITIES_CLAUSE, LEVELS_CLAUSE, MASK_COLUMN_CLAUSE, MASK_CLAUSE, IS_ADMIN_CLAUSE, IS_OWNER_CLAUSE],
|
|
74
|
+
...APP_MEMBER_LIST
|
|
75
|
+
},
|
|
76
|
+
AuthzColumnSecurity: {
|
|
77
|
+
text: 'Limits who may write {columns}, and never gives access to a row: a write that matches the {rule} pattern fails unless the writer passes the attached rule.',
|
|
78
|
+
clauses: [
|
|
79
|
+
{ when: 'authz', text: 'The attached rule: {authz}' },
|
|
80
|
+
{ when: 'allow_system', text: 'Work the system runs itself always passes.' },
|
|
81
|
+
{ when: 'values', text: 'Protected values: {values}.' },
|
|
82
|
+
{ when: 'allowed', text: 'Allowed changes: {allowed}.' },
|
|
83
|
+
{ when: 'error_code', text: 'A refused write reports the code {error_code}.' },
|
|
84
|
+
{ when: 'error_message', text: 'A refused write shows the message "{error_message}".' }
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
AuthzComposite: {
|
|
88
|
+
text: 'Combines other rules.',
|
|
89
|
+
clauses: [
|
|
90
|
+
{ when: 'BoolExpr', text: '{BoolExpr.boolop} {BoolExpr.args}' },
|
|
91
|
+
{ when: 'OR', unless: ['BoolExpr'], text: 'At least one of these must pass: {OR}' },
|
|
92
|
+
{ when: 'AND', unless: ['BoolExpr', 'OR'], text: 'All of these must pass: {AND}' },
|
|
93
|
+
{ when: 'NOT', unless: ['BoolExpr', 'OR', 'AND'], text: 'This must not pass: {NOT}' }
|
|
94
|
+
],
|
|
95
|
+
values: {
|
|
96
|
+
'BoolExpr.boolop': {
|
|
97
|
+
AND_EXPR: 'All of these must pass:',
|
|
98
|
+
OR_EXPR: 'At least one of these must pass:',
|
|
99
|
+
NOT_EXPR: 'This must not pass:',
|
|
100
|
+
'*': 'These parts combine in a way these words do not describe ({value}), so the access may be wider or narrower:'
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
AuthzDatabaseClaim: {
|
|
105
|
+
text: 'Connections the platform has bound to one database; no person or team is checked.',
|
|
106
|
+
clauses: [
|
|
107
|
+
{ when: 'schema_id', text: 'The database is the one that owns the schema with id {schema_id}, so such a connection passes for every row.' },
|
|
108
|
+
{ when: 'entity_field', unless: ['schema_id'], text: 'The database is the one named in the row\'s {entity_field} column.' },
|
|
109
|
+
{ when: 'lane_attested', text: 'Only connections the platform attests for that database pass.' }
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
AuthzDenyAll: { text: 'Nobody.' },
|
|
113
|
+
AuthzDirectOwner: { text: 'The person whose id is in the row\'s {entity_field} column.' },
|
|
114
|
+
AuthzDirectOwnerAny: { text: 'Anyone whose id is in one of the row\'s columns {entity_fields}.' },
|
|
115
|
+
AuthzEntityMembership: {
|
|
116
|
+
text: 'Members of the team named in the row\'s {entity_field} column.',
|
|
117
|
+
clauses: [
|
|
118
|
+
ENTITY_TYPE_CLAUSE,
|
|
119
|
+
MEMBERSHIP_TYPE_CLAUSE,
|
|
120
|
+
CAPABILITIES_CLAUSE,
|
|
121
|
+
LEVELS_CLAUSE,
|
|
122
|
+
MASK_COLUMN_CLAUSE,
|
|
123
|
+
MASK_CLAUSE,
|
|
124
|
+
IS_ADMIN_CLAUSE,
|
|
125
|
+
IS_OWNER_CLAUSE,
|
|
126
|
+
MEMBER_LIST_CLAUSE,
|
|
127
|
+
{
|
|
128
|
+
when: 'check_function_name',
|
|
129
|
+
covers: ['check_function_schema'],
|
|
130
|
+
text: 'The function {check_function_name} decides membership instead of the member list, given the row\'s {entity_field} column.'
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
values: MEMBERSHIP_TYPE_WORDS
|
|
134
|
+
},
|
|
135
|
+
AuthzFilePath: {
|
|
136
|
+
text: 'People who hold a share of the file or one of its folders, when the share has {capability_field} set and has not expired, even people outside the team.',
|
|
137
|
+
clauses: [
|
|
138
|
+
{
|
|
139
|
+
when: 'shares_table',
|
|
140
|
+
covers: ['shares_table_id'],
|
|
141
|
+
text: 'Shares are read from the {shares_table} table.'
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
when: 'shares_table_id',
|
|
145
|
+
unless: ['shares_table'],
|
|
146
|
+
text: 'The shares table is the one with id {shares_table_id}.'
|
|
147
|
+
},
|
|
148
|
+
{ when: 'shares_schema', text: 'The shares table is in the {shares_schema} schema.' },
|
|
149
|
+
{
|
|
150
|
+
when: 'files_table',
|
|
151
|
+
covers: ['files_table_id'],
|
|
152
|
+
text: 'The files are in the {files_table} table.'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
when: 'files_table_id',
|
|
156
|
+
unless: ['files_table'],
|
|
157
|
+
text: 'The files table is the one with id {files_table_id}.'
|
|
158
|
+
},
|
|
159
|
+
{ when: 'files_schema', text: 'The files table is in the {files_schema} schema.' }
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
AuthzHumanOnly: {
|
|
163
|
+
text: 'Only a person signed in as themselves, with a session or their own API key; an agent key with its own identity does not pass.'
|
|
164
|
+
},
|
|
165
|
+
AuthzMemberList: { text: 'People whose id is listed in the row\'s {array_field} column.' },
|
|
166
|
+
AuthzMemberOwner: {
|
|
167
|
+
text: 'The person whose id is in the row\'s {owner_field} column, while they are a member of the team named in its {entity_field} column.',
|
|
168
|
+
clauses: [ENTITY_TYPE_CLAUSE, MEMBERSHIP_TYPE_CLAUSE, CAPABILITIES_CLAUSE, LEVELS_CLAUSE, MASK_COLUMN_CLAUSE, MASK_CLAUSE, IS_ADMIN_CLAUSE, IS_OWNER_CLAUSE, MEMBER_LIST_CLAUSE],
|
|
169
|
+
values: MEMBERSHIP_TYPE_WORDS
|
|
170
|
+
},
|
|
171
|
+
AuthzNotReadOnly: {
|
|
172
|
+
text: 'Only members of the team named in the row\'s {entity_field} column who are not read-only; meant as a limit on top of the policy that grants access.',
|
|
173
|
+
clauses: [ENTITY_TYPE_CLAUSE, MEMBERSHIP_TYPE_CLAUSE, MEMBER_LIST_CLAUSE],
|
|
174
|
+
values: MEMBERSHIP_TYPE_WORDS
|
|
175
|
+
},
|
|
176
|
+
AuthzOrgHierarchy: {
|
|
177
|
+
text: 'In the reporting chart of the organization named in the row\'s {entity_field} column: {direction} the person in its {anchor_field} column.',
|
|
178
|
+
clauses: [{ when: 'max_depth', text: 'Only people up to {max_depth} levels apart count.' }],
|
|
179
|
+
values: { direction: { down: 'the managers above', up: 'the people below' } }
|
|
180
|
+
},
|
|
181
|
+
AuthzPeerOwnership: {
|
|
182
|
+
text: 'Anyone who shares a team with the person whose id is in the row\'s {owner_field} column, including that person when they belong to a team.',
|
|
183
|
+
clauses: [
|
|
184
|
+
ENTITY_TYPE_CLAUSE,
|
|
185
|
+
MEMBERSHIP_TYPE_CLAUSE,
|
|
186
|
+
CAPABILITIES_CLAUSE,
|
|
187
|
+
LEVELS_CLAUSE,
|
|
188
|
+
MASK_COLUMN_CLAUSE,
|
|
189
|
+
MASK_CLAUSE,
|
|
190
|
+
IS_ADMIN_CLAUSE,
|
|
191
|
+
IS_OWNER_CLAUSE,
|
|
192
|
+
MEMBER_LIST_CLAUSE
|
|
193
|
+
],
|
|
194
|
+
values: MEMBERSHIP_TYPE_WORDS
|
|
195
|
+
},
|
|
196
|
+
AuthzPublishable: {
|
|
197
|
+
text: 'Anyone who can use the table, for rows whose {is_published_field} column is true.',
|
|
198
|
+
clauses: [
|
|
199
|
+
{
|
|
200
|
+
when: 'require_published_at',
|
|
201
|
+
text: 'The time in the {published_at_field} column must also be set and not in the future.'
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
AuthzRelatedEntityMembership: {
|
|
206
|
+
text: 'Members of the team that owns the related row the row\'s {entity_field} column points to.',
|
|
207
|
+
clauses: [
|
|
208
|
+
OBJ_TABLE_CLAUSE,
|
|
209
|
+
OBJ_TABLE_ID_CLAUSE,
|
|
210
|
+
OBJ_SCHEMA_CLAUSE,
|
|
211
|
+
{
|
|
212
|
+
when: 'obj_field',
|
|
213
|
+
covers: ['obj_field_id'],
|
|
214
|
+
text: 'The team that owns it is in its {obj_field} column.'
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
when: 'obj_field_id',
|
|
218
|
+
unless: ['obj_field'],
|
|
219
|
+
text: 'The team that owns it is in the column with id {obj_field_id}.'
|
|
220
|
+
},
|
|
221
|
+
SEL_OBJ_CLAUSE,
|
|
222
|
+
NO_SEL_OBJ_CLAUSE,
|
|
223
|
+
ENTITY_TYPE_CLAUSE,
|
|
224
|
+
MEMBERSHIP_TYPE_CLAUSE,
|
|
225
|
+
CAPABILITIES_CLAUSE,
|
|
226
|
+
LEVELS_CLAUSE,
|
|
227
|
+
MASK_COLUMN_CLAUSE,
|
|
228
|
+
MASK_CLAUSE,
|
|
229
|
+
IS_ADMIN_CLAUSE,
|
|
230
|
+
IS_OWNER_CLAUSE,
|
|
231
|
+
MEMBER_LIST_CLAUSE
|
|
232
|
+
],
|
|
233
|
+
values: MEMBERSHIP_TYPE_WORDS
|
|
234
|
+
},
|
|
235
|
+
AuthzRelatedMemberList: {
|
|
236
|
+
text: 'People whose id is listed in the {owned_table_key} column of the related row whose {owned_table_ref_key} column matches the row\'s {this_object_key} column.',
|
|
237
|
+
clauses: [
|
|
238
|
+
{
|
|
239
|
+
when: 'owned_table',
|
|
240
|
+
covers: ['owned_table_id'],
|
|
241
|
+
text: 'The related row is in the {owned_table} table.'
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
when: 'owned_table_id',
|
|
245
|
+
unless: ['owned_table'],
|
|
246
|
+
text: 'The related table is the one with id {owned_table_id}.'
|
|
247
|
+
},
|
|
248
|
+
{ when: 'owned_schema', text: 'The related table is in the {owned_schema} schema.' }
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
AuthzRelatedMemberOwner: {
|
|
252
|
+
text: 'The person whose id is in the row\'s {owner_field} column, while they are a member of the team that owns the related row its {entity_field} column points to.',
|
|
253
|
+
clauses: [
|
|
254
|
+
OBJ_TABLE_CLAUSE,
|
|
255
|
+
OBJ_TABLE_ID_CLAUSE,
|
|
256
|
+
OBJ_SCHEMA_CLAUSE,
|
|
257
|
+
{
|
|
258
|
+
when: 'obj_field',
|
|
259
|
+
covers: ['obj_field_id'],
|
|
260
|
+
text: 'The team that owns it is in its {obj_field} column.'
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
when: 'obj_field_id',
|
|
264
|
+
unless: ['obj_field'],
|
|
265
|
+
text: 'The team that owns it is in the column with id {obj_field_id}.'
|
|
266
|
+
},
|
|
267
|
+
SEL_OBJ_CLAUSE,
|
|
268
|
+
NO_SEL_OBJ_CLAUSE,
|
|
269
|
+
ENTITY_TYPE_CLAUSE,
|
|
270
|
+
MEMBERSHIP_TYPE_CLAUSE,
|
|
271
|
+
CAPABILITIES_CLAUSE,
|
|
272
|
+
LEVELS_CLAUSE,
|
|
273
|
+
MASK_COLUMN_CLAUSE,
|
|
274
|
+
MASK_CLAUSE,
|
|
275
|
+
IS_ADMIN_CLAUSE,
|
|
276
|
+
IS_OWNER_CLAUSE,
|
|
277
|
+
MEMBER_LIST_CLAUSE
|
|
278
|
+
],
|
|
279
|
+
values: MEMBERSHIP_TYPE_WORDS
|
|
280
|
+
},
|
|
281
|
+
AuthzRelatedPeerOwnership: {
|
|
282
|
+
text: 'Anyone who shares a team with the owner of the related row the row\'s {entity_field} column points to.',
|
|
283
|
+
clauses: [
|
|
284
|
+
OBJ_TABLE_CLAUSE,
|
|
285
|
+
OBJ_TABLE_ID_CLAUSE,
|
|
286
|
+
OBJ_SCHEMA_CLAUSE,
|
|
287
|
+
{ when: 'obj_field', covers: ['obj_field_id'], text: 'Its owner is in its {obj_field} column.' },
|
|
288
|
+
{
|
|
289
|
+
when: 'obj_field_id',
|
|
290
|
+
unless: ['obj_field'],
|
|
291
|
+
text: 'Its owner is in the column with id {obj_field_id}.'
|
|
292
|
+
},
|
|
293
|
+
ENTITY_TYPE_CLAUSE,
|
|
294
|
+
MEMBERSHIP_TYPE_CLAUSE,
|
|
295
|
+
CAPABILITIES_CLAUSE,
|
|
296
|
+
LEVELS_CLAUSE,
|
|
297
|
+
MASK_COLUMN_CLAUSE,
|
|
298
|
+
MASK_CLAUSE,
|
|
299
|
+
IS_ADMIN_CLAUSE,
|
|
300
|
+
IS_OWNER_CLAUSE,
|
|
301
|
+
MEMBER_LIST_CLAUSE
|
|
302
|
+
],
|
|
303
|
+
values: MEMBERSHIP_TYPE_WORDS
|
|
304
|
+
},
|
|
305
|
+
AuthzSystemOnly: {
|
|
306
|
+
text: 'Only work the system runs itself, such as triggers and background jobs; normal requests never pass.'
|
|
307
|
+
},
|
|
308
|
+
AuthzTemporal: {
|
|
309
|
+
text: 'Anyone who can use the table, while the row is inside its time window.',
|
|
310
|
+
clauses: [
|
|
311
|
+
{
|
|
312
|
+
when: 'valid_from_field',
|
|
313
|
+
text: 'The window opens {valid_from_inclusive} the time in the {valid_from_field} column.'
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
when: 'valid_until_field',
|
|
317
|
+
text: 'It closes {valid_until_inclusive} the time in the {valid_until_field} column, and an empty value never closes it.'
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
values: {
|
|
321
|
+
valid_from_inclusive: { true: 'at', false: 'just after' },
|
|
322
|
+
valid_until_inclusive: { true: 'just after', false: 'at' }
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
AuthzValueAllowed: {
|
|
326
|
+
text: 'Anyone who can use the table, for rows whose {column} column matches {allowed} (test: {operator}).'
|
|
327
|
+
},
|
|
328
|
+
AuthzValueExists: {
|
|
329
|
+
text: 'Anyone who can use the table, for rows that have a matching row in another table, counting only the rows of that table the person can see.',
|
|
330
|
+
clauses: [
|
|
331
|
+
{ when: 'ref_table', covers: ['ref_table_id'], text: 'The other table is {ref_table}.' },
|
|
332
|
+
{
|
|
333
|
+
when: 'ref_table_id',
|
|
334
|
+
unless: ['ref_table'],
|
|
335
|
+
text: 'The other table is the one with id {ref_table_id}.'
|
|
336
|
+
},
|
|
337
|
+
{ when: 'ref_module', text: 'The other table is one that an installed module made.' },
|
|
338
|
+
{ when: 'ref_schema', text: 'It is in the {ref_schema} schema.' },
|
|
339
|
+
{
|
|
340
|
+
when: 'join',
|
|
341
|
+
text: 'The rows match on the listed column pairs, each compared with its own test (equal unless it says otherwise).'
|
|
342
|
+
},
|
|
343
|
+
{ when: 'conditions', text: 'The matching row must also meet the listed conditions.' },
|
|
344
|
+
{ when: 'exists', text: 'A further matching row must also exist in a third table, by its own join and conditions.' },
|
|
345
|
+
{
|
|
346
|
+
when: 'conditions_ast',
|
|
347
|
+
text: 'The matching row must also meet stored conditions; these words do not spell them out, so the access may be narrower.'
|
|
348
|
+
}
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
AuthzValueMatch: {
|
|
352
|
+
text: 'Anyone who can use the table, for rows that have a matching row in another table, counting only the rows of that table the person can see.',
|
|
353
|
+
clauses: [
|
|
354
|
+
{ when: 'ref_table', covers: ['ref_table_id'], text: 'The other table is {ref_table}.' },
|
|
355
|
+
{
|
|
356
|
+
when: 'ref_table_id',
|
|
357
|
+
unless: ['ref_table'],
|
|
358
|
+
text: 'The other table is the one with id {ref_table_id}.'
|
|
359
|
+
},
|
|
360
|
+
{ when: 'ref_module', text: 'The other table is one that an installed module made.' },
|
|
361
|
+
{ when: 'ref_schema', text: 'It is in the {ref_schema} schema.' },
|
|
362
|
+
{
|
|
363
|
+
when: 'match',
|
|
364
|
+
text: 'The other row\'s {match.ref_column} column must match {match.allowed} (test: {match.operator}).'
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
when: 'join',
|
|
368
|
+
text: 'The rows match on the listed column pairs, each compared with its own test (equal unless it says otherwise).'
|
|
369
|
+
},
|
|
370
|
+
{ when: 'conditions', text: 'The matching row must also meet the listed conditions.' },
|
|
371
|
+
{ when: 'exists', text: 'A further matching row must also exist in a third table, by its own join and conditions.' },
|
|
372
|
+
{
|
|
373
|
+
when: 'conditions_ast',
|
|
374
|
+
text: 'The matching row must also meet stored conditions; these words do not spell them out, so the access may be narrower.'
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
when: 'outer_conditions_ast',
|
|
378
|
+
text: 'The row itself must also meet stored conditions; these words do not spell them out, so the access may be narrower.'
|
|
379
|
+
}
|
|
380
|
+
]
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
function partNotDescribed({ within, negated }) {
|
|
384
|
+
const effect = negated || within === 'either' ? 'wider or narrower' : within === 'or' ? 'wider' : 'narrower';
|
|
385
|
+
return `A part that these words do not describe, so the access may be ${effect}.`;
|
|
386
|
+
}
|
|
387
|
+
const BOOL_OPS = { OR_EXPR: 'or', AND_EXPR: 'and' };
|
|
388
|
+
const COMBINATORS = new Set(['AND', 'OR', 'NOT', 'BoolExpr']);
|
|
389
|
+
function lookup(values, path) {
|
|
390
|
+
return path.split('.').reduce((value, key) => value?.[key], values);
|
|
391
|
+
}
|
|
392
|
+
// The position of the parts a composite parameter holds.
|
|
393
|
+
function positionOf(param, values, negated) {
|
|
394
|
+
if (param === 'OR')
|
|
395
|
+
return { within: 'or', negated };
|
|
396
|
+
if (param === 'AND')
|
|
397
|
+
return { within: 'and', negated };
|
|
398
|
+
if (param === 'NOT')
|
|
399
|
+
return { within: 'either', negated: true };
|
|
400
|
+
if (param === 'BoolExpr.args') {
|
|
401
|
+
const op = String(lookup(values, 'BoolExpr.boolop'));
|
|
402
|
+
return op === 'NOT_EXPR' ? { within: 'either', negated: true } : { within: BOOL_OPS[op] ?? 'either', negated };
|
|
403
|
+
}
|
|
404
|
+
return { within: 'either', negated };
|
|
405
|
+
}
|
|
406
|
+
const notDescribed = (key) => `The setting "${key}" is set, and these words do not describe it, so the access may be wider or narrower.`;
|
|
407
|
+
const notRead = (key) => `The setting "${key}" is stored, and this rule does not read it.`;
|
|
408
|
+
// Where the backend may build one node (not its nested parts) into another check than its words: a shape the rule check
|
|
409
|
+
// does not support, and a related member list whose related table's columns are not known, so it cannot be ruled out.
|
|
410
|
+
function unstatedShapes(type, data, related) {
|
|
411
|
+
const columns = columnsOf(related);
|
|
412
|
+
const values = { ...defaultsOf(type), ...data };
|
|
413
|
+
const shapes = unsupportedShapes(type, data, { inBlueprint: true, columnsOf: columns }).map(({ path }) => `This rule does not support the column name "${String(lookup(values, path))}" in "${path}" here, so it may not check what these words say.`);
|
|
414
|
+
if (type === 'AuthzRelatedMemberList' && columns({ id: values.owned_table_id, name: values.owned_table }) === undefined) {
|
|
415
|
+
shapes.push(`These words cannot tell whether the related table also has a column named "${String(values.this_object_key)}", which this rule does not support; ` +
|
|
416
|
+
'if it has one, the rule may not check what they say.');
|
|
417
|
+
}
|
|
418
|
+
return shapes;
|
|
419
|
+
}
|
|
420
|
+
// A key the backend reads from a rule's data: one of its node's parameters, a member key these tools do not support, or
|
|
421
|
+
// any part of a composite, whose raw parts the backend builds too.
|
|
422
|
+
const readsKey = (type, key) => type === 'AuthzComposite' || AUTHZ_NODES.get(type)?.parameter_schema.properties?.[key] !== undefined || READ_BUT_NOT_SUPPORTED.includes(key);
|
|
423
|
+
function hasValue(value) {
|
|
424
|
+
if (Array.isArray(value))
|
|
425
|
+
return value.length > 0;
|
|
426
|
+
return value !== undefined && value !== null && value !== false && value !== '';
|
|
427
|
+
}
|
|
428
|
+
function describeValue(value, position, related) {
|
|
429
|
+
if (Array.isArray(value)) {
|
|
430
|
+
return value.every((item) => typeof item === 'object' && item !== null)
|
|
431
|
+
? value.map((item, i) => `(${i + 1}) ${describeValue(item, position, related)}`).join(' ')
|
|
432
|
+
: value.map((item) => describeValue(item, position, related)).join(', ');
|
|
433
|
+
}
|
|
434
|
+
if (isObject(value)) {
|
|
435
|
+
const keys = Object.keys(value);
|
|
436
|
+
if (keys.length === 1 && AUTHZ_NODES.has(keys[0]) && isObject(value[keys[0]])) {
|
|
437
|
+
return sentenceOf(keys[0], value[keys[0]], position.negated, related);
|
|
438
|
+
}
|
|
439
|
+
if (keys.some((key) => COMBINATORS.has(key)))
|
|
440
|
+
return sentenceOf('AuthzComposite', value, position.negated, related);
|
|
441
|
+
return partNotDescribed(position);
|
|
442
|
+
}
|
|
443
|
+
return String(value);
|
|
444
|
+
}
|
|
445
|
+
function describeParam(words, param, value, values, negated, related) {
|
|
446
|
+
const named = words.values?.[param];
|
|
447
|
+
const phrase = named?.[String(value)] ?? named?.['*'];
|
|
448
|
+
const position = positionOf(param, values, negated);
|
|
449
|
+
return phrase === undefined ? describeValue(value, position, related) : phrase.replace('{value}', describeValue(value, position, related));
|
|
450
|
+
}
|
|
451
|
+
// A key changes the rule when it differs from its default; one with no default changes it only when it has a value
|
|
452
|
+
// (`is_admin: false` does not).
|
|
453
|
+
function changesPolicy(defaults, param, value) {
|
|
454
|
+
if (defaults[param] === undefined)
|
|
455
|
+
return hasValue(value);
|
|
456
|
+
return value !== undefined && value !== null && JSON.stringify(defaults[param]) !== JSON.stringify(value);
|
|
457
|
+
}
|
|
458
|
+
function templateOf(type) {
|
|
459
|
+
const words = POLICY_WORDS[type];
|
|
460
|
+
if (!words) {
|
|
461
|
+
throw new Error(`explainPolicy: "${type}" is not an Authz node, so it has no plain words. ` +
|
|
462
|
+
'Pass the name of an Authz node, for example "AuthzEntityMembership" (the registry\'s nodes with category "authz").');
|
|
463
|
+
}
|
|
464
|
+
return words;
|
|
465
|
+
}
|
|
466
|
+
// The sentence of one rule, the keys of its own data the sentence does not describe, and the shapes it hedges.
|
|
467
|
+
function wordsOf(type, data, negated, related) {
|
|
468
|
+
const effective = effectivePolicy(type, data ?? {});
|
|
469
|
+
const words = templateOf(effective.type);
|
|
470
|
+
const given = effective.data;
|
|
471
|
+
const defaults = defaultsOf(effective.type);
|
|
472
|
+
const values = { ...defaults, ...words.assumes, ...given };
|
|
473
|
+
const described = derivedKeys(effective.type, given);
|
|
474
|
+
const fill = (template) => template.replace(/\{([A-Za-z_][A-Za-z_.]*)\}/g, (_match, param) => {
|
|
475
|
+
const value = lookup(values, param);
|
|
476
|
+
if (value === undefined || value === null) {
|
|
477
|
+
throw new Error(`explainPolicy: the ${effective.type} sentence names "${param}", but the rule's data has no value for it. Add "${param}" to the rule's data.`);
|
|
478
|
+
}
|
|
479
|
+
described.add(param.split('.')[0]);
|
|
480
|
+
return describeParam(words, param, value, values, negated, related);
|
|
481
|
+
});
|
|
482
|
+
const parts = [fill(words.text)];
|
|
483
|
+
for (const clause of words.clauses ?? []) {
|
|
484
|
+
if (!hasValue(values[clause.when])) {
|
|
485
|
+
described.add(clause.when);
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (clause.unless?.some((key) => hasValue(values[key])))
|
|
489
|
+
continue;
|
|
490
|
+
parts.push(fill(clause.text));
|
|
491
|
+
described.add(clause.when);
|
|
492
|
+
for (const key of clause.covers ?? [])
|
|
493
|
+
described.add(key);
|
|
494
|
+
}
|
|
495
|
+
const left = Object.entries(given).flatMap(([key, value]) => (!described.has(key) && changesPolicy(defaults, key, value) ? [key] : []));
|
|
496
|
+
const undescribed = left.filter((key) => readsKey(effective.type, key));
|
|
497
|
+
const unstated = effective.type === 'AuthzComposite' ? [] : unstatedShapes(effective.type, given, related);
|
|
498
|
+
const notReadKeys = left.filter((key) => !readsKey(effective.type, key));
|
|
499
|
+
return { text: [...parts, ...undescribed.map(notDescribed), ...notReadKeys.map(notRead), ...unstated].join(' '), undescribed, unstated };
|
|
500
|
+
}
|
|
501
|
+
const sentenceOf = (type, data, negated, related) => wordsOf(type, data, negated, related).text;
|
|
502
|
+
/**
|
|
503
|
+
* True when the words of one rule's own data (an Authz node; its nested parts are rules of their own) state all it
|
|
504
|
+
* checks: no key they do not describe, no shape they hedge, and data they can read. Otherwise the rule may let in more
|
|
505
|
+
* or fewer people than its words say, and its words say where.
|
|
506
|
+
*/
|
|
507
|
+
export function statesAll(type, data, related) {
|
|
508
|
+
try {
|
|
509
|
+
const { undescribed, unstated } = wordsOf(type, data, false, related);
|
|
510
|
+
return undescribed.length === 0 && unstated.length === 0;
|
|
511
|
+
}
|
|
512
|
+
catch {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* One rule in plain words: the node's sentence filled from `data` (registry defaults apply), then each clause that
|
|
518
|
+
* applies, then one sentence for every key of `data` that none of those parts describes, and one for each shape the
|
|
519
|
+
* backend may build into another check. A nested Authz node or AND/OR/NOT part inside the data is explained in turn.
|
|
520
|
+
* `related` holds the columns of the other tables the rule names, when the reader read them.
|
|
521
|
+
*/
|
|
522
|
+
export function explainPolicy(type, data, related) {
|
|
523
|
+
return sentenceOf(type, data, false, related);
|
|
524
|
+
}
|
package/esm/app-workspace.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare function ensureAppScaffold(cwd: string, exec?: RunCommand): Promi
|
|
|
30
30
|
ok: boolean;
|
|
31
31
|
out: string;
|
|
32
32
|
}>;
|
|
33
|
+
export declare function composedInstallComplete(appDir: string): boolean;
|
|
33
34
|
export declare function ensureComposedInstall(cwd: string, exec?: RunCommand): Promise<{
|
|
34
35
|
ok: boolean;
|
|
35
36
|
out: string;
|
package/esm/app-workspace.js
CHANGED
|
@@ -14,9 +14,9 @@ const execFileAsync = promisify(execFile);
|
|
|
14
14
|
// with `Cannot find module 'graphile-connection-filter'`. Hoisting the override
|
|
15
15
|
// to the ROOT pnpm-workspace.yaml (which pnpm 11.8 DOES read) collapses graphql —
|
|
16
16
|
// and therefore grafast — to a single version, and the missing module resolves
|
|
17
|
-
//
|
|
17
|
+
// We also strip the nested packages/app
|
|
18
18
|
// pnpm-workspace.yaml the template ships, and keep onlyBuiltDependencies so the
|
|
19
|
-
// native deps build where honored
|
|
19
|
+
// native deps build where honored.
|
|
20
20
|
export const NATIVE_BUILD_DEPS = ['esbuild', 'sharp', 'unrs-resolver'];
|
|
21
21
|
export const IGNORED_BUILDS_RE = /ERR_PNPM_IGNORED_BUILDS|Ignored build scripts/;
|
|
22
22
|
const DEFAULT_GRAPHQL_OVERRIDE = '16.14.0';
|
|
@@ -95,8 +95,7 @@ export async function ensureWorkspaceConfig(cwd) {
|
|
|
95
95
|
await writeFile(path.join(cwd, 'pnpm-workspace.yaml'), text);
|
|
96
96
|
}
|
|
97
97
|
// Force @constructive-io/graphql-codegen to `latest` in the app package.json
|
|
98
|
-
// before the single install — older 4.9.x throws on PostGraphile `filter` inputs
|
|
99
|
-
// (TS-001).
|
|
98
|
+
// before the single install — older 4.9.x throws on PostGraphile `filter` inputs.
|
|
100
99
|
export async function pinCodegenLatest(appDir) {
|
|
101
100
|
const pkgPath = path.join(appDir, 'package.json');
|
|
102
101
|
const pkg = JSON.parse(await readFile(pkgPath, 'utf8'));
|
|
@@ -109,16 +108,14 @@ export async function pinCodegenLatest(appDir) {
|
|
|
109
108
|
}
|
|
110
109
|
// The Constructive Next.js app is just the `nextjs/constructive-app` tree from
|
|
111
110
|
// the sandbox-templates repo — it ships no `____VAR____` placeholders, so there
|
|
112
|
-
// is nothing to templatize.
|
|
113
|
-
//
|
|
114
|
-
// for minutes. Materialize `packages/app` deterministically by shallow-cloning
|
|
115
|
-
// the template instead (PGPM-001).
|
|
111
|
+
// is nothing to templatize. Materialize `packages/app` deterministically by
|
|
112
|
+
// shallow-cloning the template.
|
|
116
113
|
export async function ensureAppScaffold(cwd, exec = run) {
|
|
117
114
|
const appDir = path.join(cwd, 'packages', 'app');
|
|
118
115
|
if (existsSync(path.join(appDir, 'package.json'))) {
|
|
119
116
|
return { ok: true, out: 'packages/app already scaffolded' };
|
|
120
117
|
}
|
|
121
|
-
const tmp = path.join(os.tmpdir(), `
|
|
118
|
+
const tmp = path.join(os.tmpdir(), `constructive-app-template-${process.pid}`);
|
|
122
119
|
await rm(tmp, { recursive: true, force: true });
|
|
123
120
|
const clone = await exec('git', ['clone', '--depth', '1', TEMPLATE_REPO, tmp], cwd);
|
|
124
121
|
if (!clone.ok) {
|
|
@@ -147,7 +144,7 @@ export async function ensureAppScaffold(cwd, exec = run) {
|
|
|
147
144
|
// pnpm writes node_modules/.modules.yaml once an install finishes linking, so a
|
|
148
145
|
// partial install (interrupted, or failed mid-way) lacks it. Codegen also
|
|
149
146
|
// needs its bin, so both must be there to skip the install.
|
|
150
|
-
function composedInstallComplete(appDir) {
|
|
147
|
+
export function composedInstallComplete(appDir) {
|
|
151
148
|
const modules = path.join(appDir, 'node_modules');
|
|
152
149
|
return (existsSync(path.join(modules, '.modules.yaml')) &&
|
|
153
150
|
existsSync(path.join(modules, '.bin', 'graphql-codegen')));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The blueprint the backend receives, with every key the caller gave. A new table (one with a table_name) gets DataId,
|
|
3
|
+
* its own nodes, the Data nodes its rules need (node-type-registry's `dataNodesForPolicies`) and DataTimestamps; row
|
|
4
|
+
* security and the default grants when it gives none; each rule's role, privileges and kind when it gives none; and its
|
|
5
|
+
* fields, each field's type and default in the backend's form. An entry that attaches to
|
|
6
|
+
* a module's table, and every other key of the definition, goes as given. Nothing here checks the blueprint: the
|
|
7
|
+
* registry's JSON Schema and the backend do.
|
|
8
|
+
*/
|
|
9
|
+
export declare function expandBlueprintDefaults(definition: Record<string, unknown>): Record<string, unknown>;
|