@openora/core 0.4.1-canary.34 → 0.4.1-canary.36
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/bin/migrate.mjs +55 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/audit/plugin.d.ts.map +1 -1
- package/dist/audit/plugin.js +4 -2
- package/dist/audit/plugin.js.map +1 -1
- package/dist/casino/gaming/__tests__/gaming.service.test.js +18 -2
- package/dist/casino/gaming/__tests__/gaming.service.test.js.map +1 -1
- package/dist/casino/gaming/plugin.d.ts.map +1 -1
- package/dist/casino/gaming/plugin.js +3 -2
- package/dist/casino/gaming/plugin.js.map +1 -1
- package/dist/casino/gaming/router/index.d.ts.map +1 -1
- package/dist/casino/gaming/router/index.js +2 -2
- package/dist/casino/gaming/router/index.js.map +1 -1
- package/dist/casino/gaming/service/gaming.service.d.ts +4 -2
- package/dist/casino/gaming/service/gaming.service.d.ts.map +1 -1
- package/dist/casino/gaming/service/gaming.service.js +8 -2
- package/dist/casino/gaming/service/gaming.service.js.map +1 -1
- package/dist/compliance/__tests__/rg.contract.test.js +8 -1
- package/dist/compliance/__tests__/rg.contract.test.js.map +1 -1
- package/dist/compliance/__tests__/rg.router.test.js +35 -1
- package/dist/compliance/__tests__/rg.router.test.js.map +1 -1
- package/dist/compliance/__tests__/rg.service.test.js +73 -1
- package/dist/compliance/__tests__/rg.service.test.js.map +1 -1
- package/dist/compliance/contract/index.d.ts +26 -0
- package/dist/compliance/contract/index.d.ts.map +1 -1
- package/dist/compliance/contract/rg.d.ts +31 -0
- package/dist/compliance/contract/rg.d.ts.map +1 -1
- package/dist/compliance/contract/rg.js +8 -0
- package/dist/compliance/contract/rg.js.map +1 -1
- package/dist/compliance/plugin.d.ts.map +1 -1
- package/dist/compliance/plugin.js +2 -1
- package/dist/compliance/plugin.js.map +1 -1
- package/dist/compliance/router/index.d.ts +26 -0
- package/dist/compliance/router/index.d.ts.map +1 -1
- package/dist/compliance/router/index.js +4 -0
- package/dist/compliance/router/index.js.map +1 -1
- package/dist/compliance/service/rg.service.d.ts +11 -2
- package/dist/compliance/service/rg.service.d.ts.map +1 -1
- package/dist/compliance/service/rg.service.js +54 -12
- package/dist/compliance/service/rg.service.js.map +1 -1
- package/dist/contracts/adapters/admin-user-directory.d.ts +1 -0
- package/dist/contracts/adapters/admin-user-directory.d.ts.map +1 -1
- package/dist/contracts/adapters/admin-user-directory.js.map +1 -1
- package/dist/contracts/adapters/email-template.d.ts +15 -1
- package/dist/contracts/adapters/email-template.d.ts.map +1 -1
- package/dist/contracts/adapters/email-template.js +29 -0
- package/dist/contracts/adapters/email-template.js.map +1 -1
- package/dist/contracts/adapters/index.d.ts +2 -0
- package/dist/contracts/adapters/index.d.ts.map +1 -1
- package/dist/contracts/adapters/index.js +1 -0
- package/dist/contracts/adapters/index.js.map +1 -1
- package/dist/contracts/adapters/play-eligibility.d.ts +15 -0
- package/dist/contracts/adapters/play-eligibility.d.ts.map +1 -0
- package/dist/contracts/adapters/play-eligibility.js +3 -0
- package/dist/contracts/adapters/play-eligibility.js.map +1 -0
- package/dist/contracts/schemas/events.d.ts +9 -0
- package/dist/contracts/schemas/events.d.ts.map +1 -1
- package/dist/contracts/schemas/events.js +18 -11
- package/dist/contracts/schemas/events.js.map +1 -1
- package/dist/pam/identity/__tests__/play-eligibility.test.d.ts +2 -0
- package/dist/pam/identity/__tests__/play-eligibility.test.d.ts.map +1 -0
- package/dist/pam/identity/__tests__/play-eligibility.test.js +30 -0
- package/dist/pam/identity/__tests__/play-eligibility.test.js.map +1 -0
- package/dist/pam/identity/admin-user-directory.d.ts +2 -1
- package/dist/pam/identity/admin-user-directory.d.ts.map +1 -1
- package/dist/pam/identity/admin-user-directory.js +2 -3
- package/dist/pam/identity/admin-user-directory.js.map +1 -1
- package/dist/pam/identity/plugin.d.ts.map +1 -1
- package/dist/pam/identity/plugin.js +3 -1
- package/dist/pam/identity/plugin.js.map +1 -1
- package/dist/pam/identity/service/play-eligibility.service.d.ts +8 -0
- package/dist/pam/identity/service/play-eligibility.service.d.ts.map +1 -0
- package/dist/pam/identity/service/play-eligibility.service.js +21 -0
- package/dist/pam/identity/service/play-eligibility.service.js.map +1 -0
- package/dist/pam/player-management/contract/index.js +1 -1
- package/dist/server/plugin-host/load-extensions.d.ts +2 -2
- package/dist/server/plugin-host/load-extensions.js +2 -2
- package/dist/server/plugin-host/load-plugins.d.ts +1 -1
- package/dist/server/plugin-host/load-plugins.d.ts.map +1 -1
- package/dist/server/plugin-host/load-plugins.js.map +1 -1
- package/dist/wallet/__tests__/wallet-commands.service.test.js +21 -3
- package/dist/wallet/__tests__/wallet-commands.service.test.js.map +1 -1
- package/dist/wallet/plugin.d.ts.map +1 -1
- package/dist/wallet/plugin.js +2 -2
- package/dist/wallet/plugin.js.map +1 -1
- package/dist/wallet/service/wallet-commands.service.d.ts +4 -1
- package/dist/wallet/service/wallet-commands.service.d.ts.map +1 -1
- package/dist/wallet/service/wallet-commands.service.js +9 -1
- package/dist/wallet/service/wallet-commands.service.js.map +1 -1
- package/{turbo-generators → generators}/src/config.ts +194 -97
- package/{turbo-generators → generators}/src/templates/contract.hbs +5 -4
- package/generators/src/templates/module/agents.hbs +17 -0
- package/{turbo-generators → generators}/src/templates/module/drizzle.config.hbs +5 -5
- package/generators/src/templates/module/index.hbs +5 -0
- package/generators/src/templates/module/migrate.hbs +17 -0
- package/{turbo-generators → generators}/src/templates/module/plugin.hbs +1 -3
- package/{turbo-generators → generators}/src/templates/module/router.hbs +5 -5
- package/generators/src/templates/module/schema.hbs +14 -0
- package/{turbo-generators → generators}/src/templates/module/service.hbs +6 -6
- package/package.json +44 -6
- package/turbo-generators/src/templates/module/agents.hbs +0 -26
- package/turbo-generators/src/templates/module/index.hbs +0 -5
- package/turbo-generators/src/templates/module/migrate.hbs +0 -15
- package/turbo-generators/src/templates/module/package.json.hbs +0 -62
- package/turbo-generators/src/templates/module/schema.hbs +0 -21
- package/turbo-generators/src/templates/module/tsconfig.json.hbs +0 -8
- /package/{turbo-generators → generators}/src/templates/adapter.hbs +0 -0
- /package/{turbo-generators → generators}/src/templates/adr.hbs +0 -0
- /package/{turbo-generators → generators}/src/templates/config.hbs +0 -0
- /package/{turbo-generators → generators}/src/templates/job-worker.hbs +0 -0
- /package/{turbo-generators → generators}/src/templates/plugin.hbs +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { implement } from '@orpc/server';
|
|
2
|
-
import { type OssContext } from '@openora/core';
|
|
3
|
-
import {
|
|
2
|
+
import { type OssContext } from '@openora/core/server';
|
|
3
|
+
import { {{camelCase name}}Contract } from '../contract/index.js';
|
|
4
4
|
import { {{pascalCase name}}Service } from '../service/{{kebabCase name}}.service.js';
|
|
5
5
|
|
|
6
6
|
// oRPC router factory for {{pascalCase name}}. plugin.ts builds the service from the
|
|
@@ -8,12 +8,12 @@ import { {{pascalCase name}}Service } from '../service/{{kebabCase name}}.servic
|
|
|
8
8
|
// thin: resolve the caller, call the service, map domain errors - no business rules.
|
|
9
9
|
// Admin-only procedures MUST `await adminGuard.assert(context)` first (lint: require-admin-guard).
|
|
10
10
|
export function create{{pascalCase name}}Router({{camelCase name}}: {{pascalCase name}}Service) {
|
|
11
|
-
const os = implement(
|
|
11
|
+
const os = implement({{camelCase name}}Contract).$context<OssContext>();
|
|
12
12
|
|
|
13
13
|
return os.router({
|
|
14
14
|
list: os.list.handler(() => {{camelCase name}}.list()),
|
|
15
15
|
|
|
16
|
-
// AGENT: add more procedures here. Define their shapes in
|
|
17
|
-
//
|
|
16
|
+
// AGENT: add more procedures here. Define their shapes in this module's
|
|
17
|
+
// contract/index.ts, never inline Zod here.
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { pgTable, uuid, timestamp } from 'drizzle-orm/pg-core';
|
|
2
|
+
|
|
3
|
+
// Drizzle tables owned by the {{pascalCase name}} module.
|
|
4
|
+
// Rules:
|
|
5
|
+
// - Column names come from the key via the snake_case casing config - never pass
|
|
6
|
+
// an explicit string (lint: drizzle-snake-case).
|
|
7
|
+
// - Timestamps are always `withTimezone` (lint: no-naive-timestamp).
|
|
8
|
+
// - Do NOT add FK references to tables owned by another domain - reference by id.
|
|
9
|
+
export const {{camelCase name}} = pgTable('{{snakeCase name}}', {
|
|
10
|
+
id: uuid().primaryKey().defaultRandom(),
|
|
11
|
+
createdAt: timestamp({ withTimezone: true }).notNull().defaultNow(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type {{pascalCase name}} = typeof {{camelCase name}}.$inferSelect;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DrizzleService } from '@openora/
|
|
2
|
-
import { type EventBus } from '@openora/core';
|
|
1
|
+
import { type DrizzleService, type EventBus } from '@openora/core/server';
|
|
3
2
|
import { {{camelCase name}} } from '../schema/index.js';
|
|
4
3
|
|
|
5
4
|
// Pure business logic for {{pascalCase name}}. A plain class wired by plugin.ts via
|
|
6
5
|
// the composition container (no decorators). Methods read as data-in/data-out
|
|
7
6
|
// transforms; isolate side effects (DB writes, event emits) at the edges. Throw
|
|
8
|
-
// domain errors (makeNotFoundError from @openora/core), never HTTP/transport errors.
|
|
7
|
+
// domain errors (makeNotFoundError from @openora/core/server), never HTTP/transport errors.
|
|
9
8
|
// Money mutations MUST run inside `this.drizzle.db.transaction(...)` (lint: money-in-transaction).
|
|
10
9
|
export class {{pascalCase name}}Service {
|
|
11
10
|
constructor(
|
|
@@ -16,10 +15,11 @@ export class {{pascalCase name}}Service {
|
|
|
16
15
|
// Reference list method - the scaffolded `list` route delegates here. Replace the
|
|
17
16
|
// projection / add filters as your domain needs. Selecting only contract fields
|
|
18
17
|
// keeps the return type aligned with the output schema.
|
|
19
|
-
async list()
|
|
20
|
-
|
|
21
|
-
.select({ id: {{camelCase name}}.id,
|
|
18
|
+
async list() {
|
|
19
|
+
const rows = await this.drizzle.db
|
|
20
|
+
.select({ id: {{camelCase name}}.id, createdAt: {{camelCase name}}.createdAt })
|
|
22
21
|
.from({{camelCase name}});
|
|
22
|
+
return rows.map((row) => ({ ...row, createdAt: row.createdAt.toISOString() }));
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// AGENT: implement here - add the module's business methods below.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openora/core",
|
|
3
|
-
"version": "0.4.1-canary.
|
|
3
|
+
"version": "0.4.1-canary.36",
|
|
4
4
|
"description": "Open-source, headless, plugin-based, AI-native iGaming framework - domain modules, plugin engine, Zod-first contracts, typed React SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai-native",
|
|
@@ -21,11 +21,15 @@
|
|
|
21
21
|
"url": "git+https://github.com/blurifycom/openora.git",
|
|
22
22
|
"directory": "packages/core"
|
|
23
23
|
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"openora-migrate": "./bin/migrate.mjs"
|
|
26
|
+
},
|
|
24
27
|
"files": [
|
|
28
|
+
"bin",
|
|
25
29
|
"dist",
|
|
26
30
|
"tsconfig",
|
|
27
31
|
"oxlint",
|
|
28
|
-
"
|
|
32
|
+
"generators",
|
|
29
33
|
"LICENSE",
|
|
30
34
|
"LICENSE-COMMERCIAL.md"
|
|
31
35
|
],
|
|
@@ -34,7 +38,7 @@
|
|
|
34
38
|
"./package.json": "./package.json",
|
|
35
39
|
"./tsconfig/*": "./tsconfig/*",
|
|
36
40
|
"./oxlint/*": "./oxlint/*",
|
|
37
|
-
"./
|
|
41
|
+
"./generators": "./generators/src/config.ts",
|
|
38
42
|
"./contracts": {
|
|
39
43
|
"import": "./dist/contracts/index.js",
|
|
40
44
|
"require": "./dist/contracts/index.js",
|
|
@@ -509,6 +513,41 @@
|
|
|
509
513
|
"types": "./dist/common/errors/index.d.ts",
|
|
510
514
|
"import": "./dist/common/errors/index.js",
|
|
511
515
|
"default": "./dist/common/errors/index.js"
|
|
516
|
+
},
|
|
517
|
+
"./player": {
|
|
518
|
+
"types": "./dist/player/index.d.ts",
|
|
519
|
+
"import": "./dist/player/index.js",
|
|
520
|
+
"default": "./dist/player/index.js"
|
|
521
|
+
},
|
|
522
|
+
"./player/contracts": {
|
|
523
|
+
"types": "./dist/player/contracts.d.ts",
|
|
524
|
+
"import": "./dist/player/contracts.js",
|
|
525
|
+
"default": "./dist/player/contracts.js"
|
|
526
|
+
},
|
|
527
|
+
"./player/server": {
|
|
528
|
+
"types": "./dist/player/server.d.ts",
|
|
529
|
+
"import": "./dist/player/server.js",
|
|
530
|
+
"default": "./dist/player/server.js"
|
|
531
|
+
},
|
|
532
|
+
"./player/contracts/eval-tournament": {
|
|
533
|
+
"types": "./dist/player/eval-tournament/contract/index.d.ts",
|
|
534
|
+
"import": "./dist/player/eval-tournament/contract/index.js",
|
|
535
|
+
"default": "./dist/player/eval-tournament/contract/index.js"
|
|
536
|
+
},
|
|
537
|
+
"./player/schema/eval-tournament": {
|
|
538
|
+
"types": "./dist/player/eval-tournament/schema/index.d.ts",
|
|
539
|
+
"import": "./dist/player/eval-tournament/schema/index.js",
|
|
540
|
+
"default": "./dist/player/eval-tournament/schema/index.js"
|
|
541
|
+
},
|
|
542
|
+
"./player/plugins/eval-tournament": {
|
|
543
|
+
"types": "./dist/player/eval-tournament/plugin.d.ts",
|
|
544
|
+
"import": "./dist/player/eval-tournament/plugin.js",
|
|
545
|
+
"default": "./dist/player/eval-tournament/plugin.js"
|
|
546
|
+
},
|
|
547
|
+
"./player/migrate/eval-tournament": {
|
|
548
|
+
"types": "./dist/player/eval-tournament/migrate.d.ts",
|
|
549
|
+
"import": "./dist/player/eval-tournament/migrate.js",
|
|
550
|
+
"default": "./dist/player/eval-tournament/migrate.js"
|
|
512
551
|
}
|
|
513
552
|
},
|
|
514
553
|
"publishConfig": {
|
|
@@ -564,11 +603,10 @@
|
|
|
564
603
|
"scripts": {
|
|
565
604
|
"build": "tsc && node scripts/copy-drizzle.mjs",
|
|
566
605
|
"watch": "tsc --w",
|
|
567
|
-
"
|
|
606
|
+
"check:types": "tsc --noEmit",
|
|
568
607
|
"clean": "rm -rf dist",
|
|
569
|
-
"test": "vitest run",
|
|
570
608
|
"test:unit": "vitest run --passWithNoTests",
|
|
571
609
|
"test:integration": "vitest run --passWithNoTests",
|
|
572
|
-
"
|
|
610
|
+
"gen:drizzle": "node scripts/generate-all.mjs"
|
|
573
611
|
}
|
|
574
612
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# {{kebabCase name}}
|
|
2
|
-
|
|
3
|
-
<!-- One paragraph: what business domain this module owns and the one design decision a reader
|
|
4
|
-
must know. Point at where facts live instead of re-listing them - routes and schemas are in
|
|
5
|
-
`contract/` and `schema/index.ts` (or `list-routes module={{kebabCase name}}`), events in
|
|
6
|
-
`domainEventSchemas`. -->
|
|
7
|
-
|
|
8
|
-
This file holds ONLY what code can't say: invariants, rationale, gotchas, extension seams,
|
|
9
|
-
where-to-look pointers. Never route/table/layout/event listings - they duplicate `contract/`,
|
|
10
|
-
`schema/`, `docs/catalog.json` and drift.
|
|
11
|
-
|
|
12
|
-
## Invariants
|
|
13
|
-
|
|
14
|
-
<!-- Money/authz/idempotency/ordering rules the code enforces but a reader could miss:
|
|
15
|
-
fail-closed branches, DB guards, race windows accepted by design, "X is the single
|
|
16
|
-
writer of Y". Delete the section if the module honestly has none yet. -->
|
|
17
|
-
|
|
18
|
-
## Extension points
|
|
19
|
-
|
|
20
|
-
<!-- Ports provided/consumed (token + one line on why), events others may react to,
|
|
21
|
-
what an overlay can rebind and where the default binding lives. -->
|
|
22
|
-
|
|
23
|
-
## Don't
|
|
24
|
-
|
|
25
|
-
<!-- Module-specific bans only - global rules (cross-module imports, float money,
|
|
26
|
-
inline Zod in routers) are lint-enforced already; don't repeat them. -->
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// Public surface of the {{pascalCase name}} add-on. Export only what other packages
|
|
2
|
-
// may consume; internal implementation details stay private. Cross-module table
|
|
3
|
-
// reads go through the `@openora-addons/{{kebabCase name}}/schema` subpath.
|
|
4
|
-
export { {{pascalCase name}}Service } from './service/{{kebabCase name}}.service.js';
|
|
5
|
-
export { create{{pascalCase name}}Router } from './router/index.js';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Applies this add-on's own migration set against its own tracking table, so it never
|
|
2
|
-
// collides with sibling modules sharing the database. SQL ships in the tarball (`files`)
|
|
3
|
-
// and loads via an import.meta.url-relative path. See ADR-0020/0027.
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { runMigrations } from '@openora/core/server/migrate';
|
|
6
|
-
|
|
7
|
-
/** Apply the {{kebabCase name}} add-on migrations (idempotent: drizzle skips already-recorded ones). */
|
|
8
|
-
export function migrate(databaseUrl?: string): Promise<void> {
|
|
9
|
-
return runMigrations({
|
|
10
|
-
migrationsFolder: fileURLToPath(new URL('../drizzle/migrations', import.meta.url)),
|
|
11
|
-
migrationsTable: '__drizzle_migrations_addon_{{snakeCase name}}',
|
|
12
|
-
migrationsSchema: 'drizzle',
|
|
13
|
-
...(databaseUrl ? { databaseUrl } : {}),
|
|
14
|
-
});
|
|
15
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@openora-addons/{{kebabCase name}}",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"license": "AGPL-3.0-only",
|
|
5
|
-
"private": true,
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js",
|
|
13
|
-
"default": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"./schema": {
|
|
16
|
-
"types": "./dist/schema/index.d.ts",
|
|
17
|
-
"import": "./dist/schema/index.js",
|
|
18
|
-
"default": "./dist/schema/index.js"
|
|
19
|
-
},
|
|
20
|
-
"./plugin": {
|
|
21
|
-
"types": "./dist/plugin.d.ts",
|
|
22
|
-
"import": "./dist/plugin.js",
|
|
23
|
-
"default": "./dist/plugin.js"
|
|
24
|
-
},
|
|
25
|
-
"./migrate": {
|
|
26
|
-
"types": "./dist/migrate.d.ts",
|
|
27
|
-
"import": "./dist/migrate.js",
|
|
28
|
-
"default": "./dist/migrate.js"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"files": ["dist", "drizzle"],
|
|
32
|
-
"scripts": {
|
|
33
|
-
"build": "tsc",
|
|
34
|
-
"typecheck": "tsc --noEmit",
|
|
35
|
-
"clean": "rm -rf dist",
|
|
36
|
-
"generate": "drizzle-kit generate",
|
|
37
|
-
"test": "vitest run",
|
|
38
|
-
"test:unit": "vitest run --passWithNoTests",
|
|
39
|
-
"test:integration": "vitest run --passWithNoTests"
|
|
40
|
-
},
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"@orpc/contract": "1.14.5",
|
|
43
|
-
"@orpc/server": "1.14.5",
|
|
44
|
-
"@openora/adapters": "workspace:*",
|
|
45
|
-
"@openora/auth": "workspace:*",
|
|
46
|
-
"@openora/core": "workspace:*",
|
|
47
|
-
"@openora/db": "workspace:*",
|
|
48
|
-
"@openora/orpc-contract": "workspace:*",
|
|
49
|
-
"@openora/plugin-host": "workspace:*",
|
|
50
|
-
"@openora/shared-schemas": "workspace:*",
|
|
51
|
-
"@paralleldrive/cuid2": "3.3.0",
|
|
52
|
-
"drizzle-orm": "0.45.2",
|
|
53
|
-
"zod": "4.4.3"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@openora/vitest-config": "workspace:*",
|
|
57
|
-
"@types/node": "25.9.2",
|
|
58
|
-
"drizzle-kit": "0.31.10",
|
|
59
|
-
"typescript": "6.0.3",
|
|
60
|
-
"vitest": "4.1.8"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { pgTable, text, timestamp, index } from 'drizzle-orm/pg-core';
|
|
2
|
-
import { createId } from '@paralleldrive/cuid2';
|
|
3
|
-
|
|
4
|
-
// Drizzle tables owned by the {{pascalCase name}} module.
|
|
5
|
-
// Rules:
|
|
6
|
-
// - Every multi-tenant table MUST include a `tenantId` column (lint: require-tenant-id).
|
|
7
|
-
// - Do NOT add FK references to tables owned by other modules - reference by id.
|
|
8
|
-
// - Table names are snake_case; exported consts are camelCase.
|
|
9
|
-
export const {{camelCase name}} = pgTable(
|
|
10
|
-
'{{snakeCase name}}',
|
|
11
|
-
{
|
|
12
|
-
id: text('id')
|
|
13
|
-
.primaryKey()
|
|
14
|
-
.$defaultFn(() => createId()),
|
|
15
|
-
tenantId: text('tenantId').notNull(),
|
|
16
|
-
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
|
17
|
-
},
|
|
18
|
-
(t) => [index('{{snakeCase name}}_tenantId_idx').on(t.tenantId)],
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export type {{pascalCase name}} = typeof {{camelCase name}}.$inferSelect;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|