very-express 0.9.0-alpha → 0.10.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.
Files changed (149) hide show
  1. package/.tmp/als-proof.mjs +15 -0
  2. package/.tmp/als-proof2.mjs +9 -0
  3. package/.tmp/gen/out/.env +41 -0
  4. package/.tmp/gen/out/.vex/meta.json +381 -0
  5. package/.tmp/gen/out/Dockerfile +20 -0
  6. package/.tmp/gen/out/README.md +39 -0
  7. package/.tmp/gen/out/package.json +51 -0
  8. package/.tmp/gen/out/public/css/style.css +8 -0
  9. package/.tmp/gen/out/public/js/deleteaccount.js +80 -0
  10. package/.tmp/gen/out/public/js/login.js +59 -0
  11. package/.tmp/gen/out/public/js/logincallback.js +19 -0
  12. package/.tmp/gen/out/public/js/mytokens.js +11 -0
  13. package/.tmp/gen/out/public/js/refreshtokens.js +23 -0
  14. package/.tmp/gen/out/scripts/build.js +39 -0
  15. package/.tmp/gen/out/scripts/oacg-fix.js +83 -0
  16. package/.tmp/gen/out/tsconfig.json +30 -0
  17. package/.tmp/gen/out/tsoa.json +32 -0
  18. package/.tmp/gen/schemas/Project.json +50 -0
  19. package/.tmp/gen/schemas/Session.json +49 -0
  20. package/.tmp/gen/schemas/User.json +81 -0
  21. package/.tmp/gen/schemas/UserAuthProfiles.json +54 -0
  22. package/.tmp/gen/schemas/UserRole.json +40 -0
  23. package/.tmp/gen/schemas/UserTenant.json +39 -0
  24. package/.tmp/gen/vex.config.json +39 -0
  25. package/.tmp/gen0/out/.env +41 -0
  26. package/.tmp/gen0/out/.vex/meta.json +323 -0
  27. package/.tmp/gen0/out/Dockerfile +20 -0
  28. package/.tmp/gen0/out/README.md +39 -0
  29. package/.tmp/gen0/out/package.json +51 -0
  30. package/.tmp/gen0/out/public/css/style.css +8 -0
  31. package/.tmp/gen0/out/public/js/deleteaccount.js +80 -0
  32. package/.tmp/gen0/out/public/js/login.js +59 -0
  33. package/.tmp/gen0/out/public/js/logincallback.js +19 -0
  34. package/.tmp/gen0/out/public/js/mytokens.js +11 -0
  35. package/.tmp/gen0/out/public/js/refreshtokens.js +23 -0
  36. package/.tmp/gen0/out/scripts/build.js +39 -0
  37. package/.tmp/gen0/out/scripts/oacg-fix.js +83 -0
  38. package/.tmp/gen0/out/tsconfig.json +30 -0
  39. package/.tmp/gen0/out/tsoa.json +32 -0
  40. package/.tmp/gen0/schemas/Session.json +49 -0
  41. package/.tmp/gen0/schemas/User.json +81 -0
  42. package/.tmp/gen0/schemas/UserAuthProfiles.json +54 -0
  43. package/.tmp/gen0/schemas/UserRole.json +38 -0
  44. package/.tmp/gen0/vex.config.json +32 -0
  45. package/.tmp/gend/out/.env +41 -0
  46. package/.tmp/gend/out/.vex/meta.json +317 -0
  47. package/.tmp/gend/out/Dockerfile +20 -0
  48. package/.tmp/gend/out/README.md +39 -0
  49. package/.tmp/gend/out/package.json +51 -0
  50. package/.tmp/gend/out/public/css/style.css +8 -0
  51. package/.tmp/gend/out/public/js/deleteaccount.js +80 -0
  52. package/.tmp/gend/out/public/js/login.js +59 -0
  53. package/.tmp/gend/out/public/js/logincallback.js +19 -0
  54. package/.tmp/gend/out/public/js/mytokens.js +11 -0
  55. package/.tmp/gend/out/public/js/refreshtokens.js +23 -0
  56. package/.tmp/gend/out/scripts/build.js +39 -0
  57. package/.tmp/gend/out/scripts/oacg-fix.js +83 -0
  58. package/.tmp/gend/out/tsconfig.json +30 -0
  59. package/.tmp/gend/out/tsoa.json +32 -0
  60. package/.tmp/gend/schemas/Session.json +49 -0
  61. package/.tmp/gend/schemas/User.json +81 -0
  62. package/.tmp/gend/schemas/UserAuthProfiles.json +54 -0
  63. package/.tmp/gend/schemas/UserContact.json +40 -0
  64. package/.tmp/gend/schemas/UserNote.json +27 -0
  65. package/.tmp/gend/vex.config.json +33 -0
  66. package/.tmp/genh/out/.env +41 -0
  67. package/.tmp/genh/out/.vex/meta.json +323 -0
  68. package/.tmp/genh/out/Dockerfile +20 -0
  69. package/.tmp/genh/out/README.md +39 -0
  70. package/.tmp/genh/out/package.json +51 -0
  71. package/.tmp/genh/out/public/css/style.css +8 -0
  72. package/.tmp/genh/out/public/js/deleteaccount.js +80 -0
  73. package/.tmp/genh/out/public/js/login.js +59 -0
  74. package/.tmp/genh/out/public/js/logincallback.js +19 -0
  75. package/.tmp/genh/out/public/js/mytokens.js +11 -0
  76. package/.tmp/genh/out/public/js/refreshtokens.js +23 -0
  77. package/.tmp/genh/out/scripts/build.js +39 -0
  78. package/.tmp/genh/out/scripts/oacg-fix.js +83 -0
  79. package/.tmp/genh/out/tsconfig.json +30 -0
  80. package/.tmp/genh/out/tsoa.json +32 -0
  81. package/.tmp/genh/schemas/Project.json +41 -0
  82. package/.tmp/genh/schemas/Session.json +49 -0
  83. package/.tmp/genh/schemas/User.json +81 -0
  84. package/.tmp/genh/schemas/UserAuthProfiles.json +54 -0
  85. package/.tmp/genh/schemas/UserTenant.json +39 -0
  86. package/.tmp/genh/vex.config.json +31 -0
  87. package/.tmp/gens/out/.env +41 -0
  88. package/.tmp/gens/out/.vex/meta.json +335 -0
  89. package/.tmp/gens/out/Dockerfile +20 -0
  90. package/.tmp/gens/out/README.md +39 -0
  91. package/.tmp/gens/out/package.json +51 -0
  92. package/.tmp/gens/out/public/css/style.css +8 -0
  93. package/.tmp/gens/out/public/js/deleteaccount.js +80 -0
  94. package/.tmp/gens/out/public/js/login.js +59 -0
  95. package/.tmp/gens/out/public/js/logincallback.js +19 -0
  96. package/.tmp/gens/out/public/js/mytokens.js +11 -0
  97. package/.tmp/gens/out/public/js/refreshtokens.js +23 -0
  98. package/.tmp/gens/out/scripts/build.js +39 -0
  99. package/.tmp/gens/out/scripts/oacg-fix.js +83 -0
  100. package/.tmp/gens/out/tsconfig.json +30 -0
  101. package/.tmp/gens/out/tsoa.json +32 -0
  102. package/.tmp/gens/schemas/Session.json +49 -0
  103. package/.tmp/gens/schemas/User.json +81 -0
  104. package/.tmp/gens/schemas/UserAuthProfiles.json +54 -0
  105. package/.tmp/gens/schemas/UserRole.json +38 -0
  106. package/.tmp/gens/vex.config.json +32 -0
  107. package/.tmp/npmtest/package.json +1 -0
  108. package/.tmp/ro-test +0 -0
  109. package/AGENTS.md +26 -12
  110. package/README.md +1 -0
  111. package/dist/index.js +1108 -1037
  112. package/dist/templates/_middlewares/Authentication.ts +1 -4
  113. package/dist/templates/_middlewares/UserContext.ts +31 -22
  114. package/dist/templates/_projectSettings/env +13 -12
  115. package/dist/templates/_projectSettings/package.json +2 -2
  116. package/dist/templates/_routes/FirebaseAuthUI.gen.ts +20 -0
  117. package/dist/templates/_routes/LoginUI.ts +293 -242
  118. package/dist/templates/_services/MongooseRepositoryAdapter.ts +68 -4
  119. package/dist/templates/_services/TypeOrmRepositoryAdapter.ts +68 -24
  120. package/dist/templates/_services/VexDbConnector.ts +1 -26
  121. package/dist/templates/_services/auth/JWTService.ts +13 -17
  122. package/dist/templates/_tenant/TenantScopeContext.ts +56 -0
  123. package/dist/templates/_types/auth.ts +19 -9
  124. package/dist/templates/_types/vex/VexRepository.ts +2 -2
  125. package/dist/templates/_utils/hash.ts +0 -16
  126. package/dist/templates/root/public/js/deleteaccount.js +0 -54
  127. package/dist/templates/tenantJsonSchema/UserTenant.json +33 -0
  128. package/docs/appGenerated/auth.md +84 -0
  129. package/docs/architecture/authAndRouting.md +1 -1
  130. package/docs/architecture/databaseTargets.md +18 -8
  131. package/docs/architecture/generatorPipeline.md +2 -1
  132. package/docs/features/accountDeletion.md +63 -12
  133. package/docs/features/auditFields.md +2 -2
  134. package/docs/features/dataIsolation.md +58 -31
  135. package/docs/features/tenantIsolation.md +138 -0
  136. package/docs/releaseNote/v0-10-0.md +147 -0
  137. package/docs/releaseNote/v0-8-5.md +98 -0
  138. package/docs/releaseNote/v0-9-0.md +41 -47
  139. package/docs/superpowers/specs/2026-09-22-usercontext-audit-enforcement-design.md +9 -9
  140. package/docs/vexJsonSchema.md +39 -0
  141. package/package.json +1 -1
  142. package/vex.config.json +1 -6
  143. package/vitest.config.ts +3 -0
  144. package/dist/templates/_routes/ExternalIdentityUI.gen.ts +0 -20
  145. package/dist/templates/root/public/js/externallogin.js +0 -133
  146. package/docs/features/auth.md +0 -34
  147. package/docs/features/externalIdentity.md +0 -163
  148. /package/docs/{ForeignKey.md → features/ForeignKey.md} +0 -0
  149. /package/docs/{apiUsage.md → features/apiUsage.md} +0 -0
@@ -0,0 +1,39 @@
1
+ // copy openapiDir to tsconfig's outDir
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ async function loadStripJsonComments() {
7
+ const { default: stripJsonComments } = await import('strip-json-comments');
8
+ return stripJsonComments;
9
+ }
10
+
11
+ async function main() {
12
+ // Load strip-json-comments dynamically
13
+ const stripJsonComments = await loadStripJsonComments();
14
+
15
+ const openapiDir = "src/openapi";
16
+ const tsconfigPath = "tsconfig.json"
17
+
18
+ // 1. read tsconfig.json to get outDir
19
+ const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf-8');
20
+ const tsconfig = JSON.parse(stripJsonComments(tsconfigContent));
21
+ const outDir = tsconfig.compilerOptions.outDir;
22
+
23
+ // 2. copy ./openapi to outDir
24
+ const outDirOpenapi = path.resolve(outDir, 'openapi');
25
+ if (!fs.existsSync(outDirOpenapi)) {
26
+ fs.mkdirSync(outDirOpenapi, { recursive: true });
27
+ }
28
+ fs.readdirSync(openapiDir).forEach((file) => {
29
+ fs.copyFileSync(path.resolve(openapiDir, file), path.resolve(outDirOpenapi, file));
30
+ });
31
+ }
32
+
33
+
34
+ // Execute the main function
35
+ main()
36
+ .catch(err => {
37
+ console.error(err);
38
+ process.exit(1);
39
+ });
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Fix openapi-generated filter types to allow primitives, based on swagger schema info.
4
+
5
+ import { readdirSync, readFileSync, writeFileSync } from 'fs';
6
+ import { join, dirname } from 'path';
7
+ import { fileURLToPath } from 'url';
8
+
9
+ const __dir = dirname(fileURLToPath(import.meta.url));
10
+ const modelsDir = join(__dir, '../src/api-client/models');
11
+ const swaggerPath = join(__dir, '../../api/src/openapi/swagger.json');
12
+
13
+ const swagger = JSON.parse(readFileSync(swaggerPath, 'utf8'));
14
+ const schemas = swagger?.components?.schemas ?? {};
15
+
16
+ function primitiveTypeFromSwaggerProp(prop) {
17
+ if (!prop?.anyOf) return null;
18
+ const primitive = prop.anyOf.find(s => s.type && !s['$ref']);
19
+ if (!primitive) return null;
20
+ if (primitive.type === 'boolean') return 'boolean';
21
+ if (primitive.type === 'number' || primitive.type === 'integer') return 'number';
22
+ return 'string';
23
+ }
24
+
25
+ function primitiveTypeFromTsTypeName(tsType, swaggerEntityName, fieldKey) {
26
+ if (tsType === 'FieldFilterBoolean') return 'boolean';
27
+ if (tsType === 'FieldFilterNumber') return 'number';
28
+ if (tsType === 'FieldFilterString') return 'string';
29
+ if (/^FieldFilter[A-Z]/.test(tsType)) return 'string';
30
+ if (swaggerEntityName && fieldKey && schemas[swaggerEntityName]?.properties) {
31
+ const swaggerKey = fieldKey === 'id' ? '_id' : fieldKey;
32
+ const prop = schemas[swaggerEntityName].properties[swaggerKey];
33
+ if (prop) return primitiveTypeFromSwaggerProp(prop);
34
+ }
35
+ return null;
36
+ }
37
+
38
+ // Field-level: FieldFilterBoolean, FilterAreaActive, FilterAreaCountryCode, etc.
39
+ const FIELD_FILTER_RE = /^(FieldFilter[A-Z]|Filter[A-Z][a-z]+[A-Z])[a-zA-Z]*\.ts$/;
40
+ // Top-level aggregates: FilterArea, FilterClient, FilterJob, etc.
41
+ const TOP_FILTER_RE = /^Filter([A-Z][a-zA-Z]+)\.ts$/;
42
+
43
+ const NULL_CHECK = ' if (value == null) {\n return value;\n }';
44
+ const PRIMITIVE_GUARD = '\n // patch: pass primitives unchanged\n if (typeof value !== \'object\') return value;';
45
+
46
+ let stats = { fieldPatched: 0, topPatched: 0, skipped: 0 };
47
+
48
+ // Pass 1: patch field-level ToJSONTyped / FromJSONTyped
49
+ for (const file of readdirSync(modelsDir)) {
50
+ if (!FIELD_FILTER_RE.test(file)) continue;
51
+ const filePath = join(modelsDir, file);
52
+ let src = readFileSync(filePath, 'utf8');
53
+ if (src.includes('// patch:') || !src.includes(NULL_CHECK)) { stats.skipped++; continue; }
54
+ src = src.replaceAll(NULL_CHECK, NULL_CHECK + PRIMITIVE_GUARD);
55
+ writeFileSync(filePath, src, 'utf8');
56
+ console.log('[patch] field v ' + file);
57
+ stats.fieldPatched++;
58
+ }
59
+
60
+ // Pass 2: patch top-level filter interface property types
61
+ for (const file of readdirSync(modelsDir)) {
62
+ const match = TOP_FILTER_RE.exec(file);
63
+ if (!match) continue;
64
+ const filePath = join(modelsDir, file);
65
+ let src = readFileSync(filePath, 'utf8');
66
+ if (src.includes('// patch:')) { stats.skipped++; continue; }
67
+ const swaggerEntityName = file.replace('.ts', '');
68
+ // Match: ` fieldName?: SomeType;` — skip $or/$and lines
69
+ const PROP_RE = /^( {4}(?!\$or|\$and)(\w+)\?:\s*)([A-Za-z]+)(;)$/gm;
70
+ let modified = false;
71
+ const patched = src.replace(PROP_RE, (line, prefix, fieldKey, tsType, semi) => {
72
+ const primitive = primitiveTypeFromTsTypeName(tsType, swaggerEntityName, fieldKey);
73
+ if (!primitive || line.includes(' | ' + primitive)) return line;
74
+ modified = true;
75
+ return prefix + tsType + ' | ' + primitive + semi;
76
+ });
77
+ if (!modified) { stats.skipped++; continue; }
78
+ writeFileSync(filePath, patched, 'utf8');
79
+ console.log('[patch] top v ' + file);
80
+ stats.topPatched++;
81
+ }
82
+
83
+ console.log('\n[patch-filter-types] Done. Field: ' + stats.fieldPatched + ', Top: ' + stats.topPatched + ', Skipped: ' + stats.skipped);
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ "baseUrl": ".",
6
+ "paths": {
7
+ "@": ["src"],
8
+ "@/*": ["src/*"]
9
+ },
10
+
11
+ /* Language and Environment */
12
+ "target": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
13
+
14
+ /* Modules */
15
+ "module": "commonjs",
16
+
17
+ /* Emit */
18
+ "outDir": "./dist", /* Specify an output folder for all emitted files. */
19
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
20
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
21
+ "allowArbitraryExtensions": true, /* Allow arbitrary file extensions. */
22
+
23
+ /* Type Checking */
24
+ "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2+ decorators. */
25
+ "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations. */
26
+ "strict": true, /* Enable all strict type-checking options. */
27
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
28
+ }
29
+ }
30
+
@@ -0,0 +1,32 @@
1
+ {
2
+ "entryFile": "src/server.ts",
3
+ "noImplicitAdditionalProperties": "throw-on-extras",
4
+ "controllerPathGlobs": [
5
+ "src/system/_controllers/**Controller.gen.ts",
6
+ "!src/system/_controllers/SessionController.gen.ts"
7
+ ],
8
+ "spec": {
9
+ "outputDirectory": "src/openapi",
10
+ "specVersion": 3,
11
+ "basePath": "/api",
12
+ "securityDefinitions": {
13
+ "BearerAuth": {
14
+ "type": "http",
15
+ "scheme": "bearer",
16
+ "bearerFormat": "JWT"
17
+ },
18
+ "AuthIndex": {
19
+ "type": "apiKey",
20
+ "in": "header",
21
+ "name": "X-Auth-Index"
22
+ }
23
+ }
24
+ },
25
+ "routes": {
26
+ "routesDir": "src/system/_routes",
27
+ "routesFileName": "tsoa_routes.ts",
28
+ "basePath": "/api",
29
+ "middleware": "express",
30
+ "authenticationModule": "src/system/_middlewares/tsoaAuthentication.gen.ts"
31
+ }
32
+ }
@@ -0,0 +1,49 @@
1
+ {
2
+ "type": "object",
3
+ "x-documentConfig": {
4
+ "documentName": "Session",
5
+ "restApi": {
6
+ "methods": [],
7
+ "joinWhitelist": []
8
+ },
9
+ "uniqueIndex": [
10
+ [
11
+ "sessionCode"
12
+ ]
13
+ ]
14
+ },
15
+ "required": [
16
+ "provider",
17
+ "userId",
18
+ "expired"
19
+ ],
20
+ "properties": {
21
+ "_id": {
22
+ "type": "string",
23
+ "x-format": "Primary",
24
+ "index": true
25
+ },
26
+ "sessionCode": {
27
+ "type": "string",
28
+ "index": true
29
+ },
30
+ "provider": {
31
+ "type": "string",
32
+ "maxLength": 30
33
+ },
34
+ "userId": {
35
+ "type": "string",
36
+ "x-format": "UUID",
37
+ "x-foreignKey": {
38
+ "schemaName": "User",
39
+ "fieldName": "_id",
40
+ "relationType": "one-to-one"
41
+ }
42
+ },
43
+ "expired": {
44
+ "type": "integer",
45
+ "x-format": "UnixTimestamp",
46
+ "description": "expired time in unix timestamp format (ms)"
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "type": "object",
3
+ "x-documentConfig": {
4
+ "documentName": "User",
5
+ "dataIsolation": {
6
+ "field": "_id"
7
+ },
8
+ "restApi": {
9
+ "methods": [
10
+ "get",
11
+ "patch"
12
+ ],
13
+ "noRelations": true,
14
+ "joinWhitelist": []
15
+ },
16
+ "isolate": {
17
+ "user": false
18
+ },
19
+ "uniqueIndex": [
20
+ [
21
+ "email"
22
+ ]
23
+ ]
24
+ },
25
+ "properties": {
26
+ "_id": {
27
+ "type": "string",
28
+ "x-format": "PrimaryUUID",
29
+ "x-vexData": "userId",
30
+ "index": true
31
+ },
32
+ "email": {
33
+ "type": "string",
34
+ "format": "email",
35
+ "index": true
36
+ },
37
+ "name": {
38
+ "type": "string",
39
+ "maxLength": 64,
40
+ "required": true
41
+ },
42
+ "active": {
43
+ "type": "boolean",
44
+ "default": true,
45
+ "required": true
46
+ },
47
+ "locale": {
48
+ "type": "string",
49
+ "maxLength": 8
50
+ },
51
+ "profileErrors": {
52
+ "type": "string"
53
+ },
54
+ "createdAt": {
55
+ "type": "string",
56
+ "x-format": "Timestamp",
57
+ "default": "onCreateTimestamp"
58
+ },
59
+ "updatedAt": {
60
+ "type": "string",
61
+ "x-format": "Timestamp",
62
+ "default": "onUpdateTimestamp"
63
+ },
64
+ "updatedBy": {
65
+ "type": "string",
66
+ "x-format": "UUID",
67
+ "default": "onUpdateUserId"
68
+ },
69
+ "deleted": {
70
+ "type": "boolean",
71
+ "default": false,
72
+ "x-vexData": "softDelete",
73
+ "description": "Soft-delete marker. Framework-managed; never client-writable. Hides the row from every ordinary query unless app.showSoftDeleted is on."
74
+ }
75
+ },
76
+ "required": [
77
+ "name",
78
+ "active",
79
+ "deleted"
80
+ ]
81
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "type": "object",
3
+ "x-documentConfig": {
4
+ "restApi": {
5
+ "methods": [],
6
+ "joinWhitelist": []
7
+ },
8
+ "documentName": "UserAuthProfiles",
9
+ "uniqueIndex": [
10
+ [
11
+ "provider",
12
+ "providerUserId"
13
+ ]
14
+ ]
15
+ },
16
+ "properties": {
17
+ "_id": {
18
+ "type": "string",
19
+ "x-format": "Primary",
20
+ "index": true
21
+ },
22
+ "userId": {
23
+ "type": "string",
24
+ "x-format": "UUID",
25
+ "index": true,
26
+ "x-foreignKey": {
27
+ "schemaName": "User",
28
+ "fieldName": "_id",
29
+ "relationType": "many-to-one"
30
+ }
31
+ },
32
+ "provider": {
33
+ "type": "string",
34
+ "index": true,
35
+ "description": "Namespace label of the identity source: an upstream IdP (\"google\"), a broker (\"firebase\"), or vex's own password path (\"local\"). The value \"local\" is reserved."
36
+ },
37
+ "providerUserId": {
38
+ "type": "string",
39
+ "index": true,
40
+ "description": "External subject within `provider`'s namespace. With `provider` it forms the account-linking key and the composite unique index. NULL for provider=\"local\". This is the subject (an OIDC `sub` or a broker user id), never a token."
41
+ },
42
+ "email": {
43
+ "type": "string"
44
+ },
45
+ "username": {
46
+ "type": "string"
47
+ },
48
+ "password": {
49
+ "type": "string",
50
+ "x-hidden": true
51
+ }
52
+ },
53
+ "required": []
54
+ }
@@ -0,0 +1,38 @@
1
+ {
2
+ "type": "object",
3
+ "x-documentConfig": {
4
+ "documentName": "UserRole",
5
+ "restApi": {
6
+ "methods": [],
7
+ "joinWhitelist": []
8
+ }
9
+ },
10
+ "properties": {
11
+ "_id": {
12
+ "type": "string",
13
+ "x-format": "Primary"
14
+ },
15
+ "userId": {
16
+ "type": "string",
17
+ "index": true,
18
+ "x-foreignKey": {
19
+ "schemaName": "User",
20
+ "fieldName": "_id",
21
+ "relationType": "many-to-one"
22
+ }
23
+ },
24
+ "role": {
25
+ "type": "string",
26
+ "x-vexData": "role",
27
+ "index": true,
28
+ "enum": [
29
+ "member"
30
+ ],
31
+ "x-format": "enum"
32
+ }
33
+ },
34
+ "required": [
35
+ "userId",
36
+ "role"
37
+ ]
38
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "jsonSchemaDir": "./schemas",
3
+ "rootDir": "./out",
4
+ "dbType": "sql",
5
+ "app": {
6
+ "enableSwagger": true,
7
+ "useUserSchema": true,
8
+ "useObjectID": true,
9
+ "allowApiCreateUpdate_id": false
10
+ },
11
+ "auth": {
12
+ "localAuth": false,
13
+ "useHttpOnlyCookieToken": false,
14
+ "oauthProviders": {
15
+ "google": false,
16
+ "github": false
17
+ },
18
+ "firebase": false
19
+ },
20
+ "useRBAC": {
21
+ "roles": [
22
+ "member"
23
+ ],
24
+ "default": "member"
25
+ },
26
+ "generator": {
27
+ "commitBeforeGenerate": false
28
+ },
29
+ "srcDir": "./out/src",
30
+ "sysDir": "./out/src/system",
31
+ "openapiDir": "./out/src/openapi"
32
+ }
@@ -0,0 +1 @@
1
+ {"name":"t","version":"0.11.0","scripts":{"preversion":"touch preversion.ran","version":"touch version.ran","postversion":"touch postversion.ran"}}
package/.tmp/ro-test ADDED
File without changes
package/AGENTS.md CHANGED
@@ -64,9 +64,19 @@ Read from `vex.config.json → jsonSchemaDir` (this repo: `./output/jsonSchema`)
64
64
  - **`src/` is ESM-style TypeScript with `~/*` → `src/*` aliasing.** Use `~/generators/...`, `~/utils/...`, `~/types/...` for intra-repo imports.
65
65
  - **Only `one-to-one` and `many-to-one` are declared in `x-foreignKey`.** `one-to-many` is derived from the other side and must not be hand-written.
66
66
  - **RBAC is opt-in.** `utils.generator.isRbacEnabled()` is the single gate for every RBAC code path. Absent `useRBAC`, or `roles: []`, means RBAC off — never "RBAC with zero roles". Never branch on `compilerOptions.useRBAC` directly.
67
- - **Auth is the only identity gate.** `UserContext` is established by `Authentication.middleware` from the verified token — there is no separate context middleware, and no generated decorator decides it. Never gate identity on `dataIsolation`: audit fields and ownership filtering are independent features. Use `utils.generator.isAuthEnabled()` when a code path depends on auth being on.
68
- - **A create that declares `onCreateUserId` with no identity in `UserContext` throws.** Both repository adapters enforce it; `onUpdateUserId` is deliberately not enforced. `dataIsolation` no longer has anything to do with whether the context exists.
67
+ - **The request scope is layered, not owned by one module.** `TenantScope.middleware` (L0 in `server.ts`) opens `UserContext`; `Authentication.middleware` (L1) adds the verified token; in tenant `option` mode `TenantScope` runs again after authentication (attached by the generated controllers) to read the claim. `UserContext.run` merges, so no layer erases another. Tenant files are emitted only when `vex.config.tenant.enable` is true; `preSelect` works with no auth module. Isolation (`isolation` rules) is independent of audit fields; use `utils.generator.isAuthEnabled()` when a code path depends on auth being on.
68
+ - **A create that declares `onCreateUserId` with no identity in `UserContext` throws.** Both repository adapters enforce it; `onUpdateUserId` is deliberately not enforced. `isolation` has nothing to do with whether the context exists.
69
69
  - **Boolean config defaults use `??`, not `||`.** `x || true` swallows an explicit `false`.
70
+ - **Never write to git.** No `git add`, `commit`, `push`, `reset`, `checkout`, `stash`, `rm`, `mv`. The
71
+ working tree is the deliverable and the user reads it with git; changes stay unstaged and
72
+ uncommitted. Reading (`status`, `diff`, `log`, `show`, `grep`) is fine.
73
+ - **Read-only mode means troubleshoot.** When the file policy is read-only, diagnose and report. Do not
74
+ attempt the edit, and do not request a wider mode — the user grants it when they want the change.
75
+ - **Only write js-doc/comment when need.** only leave js-doc/comment when things is complex and name does not tell what it does, only write short and clean comment. A comment earns its place only for what the code cannot say: a non-obvious rule, a workaround, a failure mode. If a comment would have to be edited together with the line below it, delete the comment. no history, no restating the signature.
76
+ - **Bump the version with `npm version`, never by hand.** `npm version <patch|minor|major>` runs the
77
+ `preversion` / `postversion` hooks; editing `version` in `package.json` / `package-lock.json`
78
+ yourself skips them. The `postversion` hook runs the build and pushes, so a bump is a publish
79
+ action — do it only when the user asks.
70
80
 
71
81
  ## Conventions
72
82
 
@@ -78,13 +88,6 @@ Read from `vex.config.json → jsonSchemaDir` (this repo: `./output/jsonSchema`)
78
88
  | Template function | camelCase default export beside its generator | `controllerTemplate()` |
79
89
  | Role class | `Role{Name}` | `RoleAdmin` |
80
90
 
81
- ## Release notes
82
-
83
- `docs/releaseNote/vX-Y-Z.md` is a **TL;DR index, not a document**: bullets, one screen, and only what a
84
- reader needs to *use* the change. Detail belongs in `docs/features/` — link it, do not inline it. If a
85
- release note has grown subsections, caveat blocks and rationale, that content is in the wrong file.
86
- Cover: what broke, what is new, how to turn it on, and the ordered upgrade steps.
87
-
88
91
  ## Code style
89
92
 
90
93
  - Prefer readability and maintainability.
@@ -101,6 +104,18 @@ Smart caveman. Drop articles, filler, pleasantries, hedging. Fragments fine. Kee
101
104
  - Code blocks unchanged. Caveman around code, not in code.
102
105
  - Error messages quoted exact.
103
106
 
107
+ ## Writing docs
108
+
109
+ A document describes **what is true now**, for a reader who has only this repo. Write the thing, not
110
+ the argument for it.
111
+
112
+ - **State current state, not what it avoids.** purpose docs is to tell behaviour, not history.
113
+ - **Present tense, current code.** No "will", "we decided", "earlier drafts", "on purpose", "deliberately", "was rejected". What the code does is visible in the code; what changed belongs in `docs/releaseNote/`.
114
+ - **Cut the comparison.** "unlike X", "instead of Y", "no longer Z" — describe what the code does, not the road not taken.
115
+ - **No private context.** No other repositories, projects or issue ids. A reader cannot open them, so naming one is noise. Anything learned out there is restated as a fact checkable from here.
116
+
117
+ Only `docs/plan/` (design records) and `docs/releaseNote/` (what changed, and how to migrate) narrate time. Every other document is present tense.
118
+
104
119
  ## Documentation map
105
120
 
106
121
  This file covers only what every session needs. Deeper material lives in `docs/`:
@@ -113,12 +128,11 @@ This file covers only what every session needs. Deeper material lives in `docs/`
113
128
  | [`docs/architecture/databaseTargets.md`](docs/architecture/databaseTargets.md) | mongo vs sql, repository adapter, data isolation, join whitelist |
114
129
  | [`docs/architecture/authAndRouting.md`](docs/architecture/authAndRouting.md) | tsoa, auth routes, swagger, RBAC |
115
130
  | [`docs/vexJsonSchema.md`](docs/vexJsonSchema.md) | Full JSON Schema reference — `x-documentConfig`, `x-foreignKey`, `x-format`, `x-vexData` |
116
- | [`docs/apiUsage.md`](docs/apiUsage.md) | API client guide — pagination, search, response format |
117
- | [`docs/ForeignKey.md`](docs/ForeignKey.md) | FK joins via the API `join` parameter |
118
131
  | [`docs/developmentNote.md`](docs/developmentNote.md) | Why no ts-node, esbuild/dist working dir, `FUNC{{ }}` intent |
119
132
  | [`docs/CONTRIBUTING.md`](docs/CONTRIBUTING.md) | Setup, branch/PR workflow, PR checklist |
120
- | [`docs/features/`](docs/features/) | rbac, dataIsolation, filterOperators, joinWhitelist, auditFields, accountDeletion, externalIdentity |
133
+ | [`docs/features/`](docs/features/) | foreignKey, apiUsage, rbac, dataIsolation, tenantIsolation, filterOperators, joinWhitelist, auditFields, accountDeletion |
121
134
  | [`docs/appGenerated/auth.md`](docs/appGenerated/auth.md) | JWT rolling keys, OAuth2 providers |
135
+ | [`docs/plan/`](docs/plan/) | Design records and implementation plans — the one place that narrates decisions and rejected alternatives |
122
136
  | [`docs/roadMap/`](docs/roadMap/) | Released features and version milestones |
123
137
  | [`docs/releaseNote/`](docs/releaseNote/) | Per-version release notes |
124
138
 
package/README.md CHANGED
@@ -7,6 +7,7 @@ VeryExpress is a generator that reads JSON Schema and produces a complete Expres
7
7
  - OpenAPI generation + Swagger UI
8
8
  - OAuth via `passport` (OAuth2)
9
9
  - Mongoose (MongoDB) and TypeORM(SQL) DB driver
10
+ - Per-document isolation rules: row ownership and tenant scoping
10
11
  - CLI for quick project scaffolding
11
12
 
12
13
  ## Quick Start