@sovecom/module-sdk 1.0.0-rc.1
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/LICENSE +661 -0
- package/README.md +63 -0
- package/dist/capabilities.d.ts +125 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +3 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/core-version.d.ts +13 -0
- package/dist/core-version.d.ts.map +1 -0
- package/dist/core-version.js +16 -0
- package/dist/core-version.js.map +1 -0
- package/dist/dto.d.ts +64 -0
- package/dist/dto.d.ts.map +1 -0
- package/dist/dto.js +12 -0
- package/dist/dto.js.map +1 -0
- package/dist/email.d.ts +85 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +40 -0
- package/dist/email.js.map +1 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +42 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +48 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +13 -0
- package/dist/events.js.map +1 -0
- package/dist/http.d.ts +43 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +10 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +82 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +219 -0
- package/dist/manifest.js.map +1 -0
- package/dist/module.d.ts +29 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/module.js +19 -0
- package/dist/module.js.map +1 -0
- package/dist/slots.d.ts +20 -0
- package/dist/slots.d.ts.map +1 -0
- package/dist/slots.js +47 -0
- package/dist/slots.js.map +1 -0
- package/dist/tables.d.ts +11 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +41 -0
- package/dist/tables.js.map +1 -0
- package/package.json +50 -0
package/dist/tables.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNamespacedTable = createNamespacedTable;
|
|
4
|
+
/**
|
|
5
|
+
* `createNamespacedTable`: a DDL/migration AUTHORING helper that enforces the `mod_<name>_`
|
|
6
|
+
* table-name prefix.
|
|
7
|
+
*
|
|
8
|
+
* It returns a namespaced table NAME (a DDL identifier the author uses in their migration source
|
|
9
|
+
* and `db/schema.ts`). It does NOT return a live Drizzle/pg handle or query builder — module
|
|
10
|
+
* own-table access AT RUNTIME is parameterized SQL via `sdk.tables.query/exec` (the broker's
|
|
11
|
+
* gated module-sql executor), the only data path that exists.
|
|
12
|
+
*
|
|
13
|
+
* The prefix rule mirrors `moduleManifestSchema`'s table superRefine: the module name is a
|
|
14
|
+
* lowercase slug, the table suffix is `[a-z0-9_]+`, and the full identifier is
|
|
15
|
+
* `mod_<name>_<suffix>`. This is the SAME shape the manifest's `tables` array must satisfy, so an
|
|
16
|
+
* author can feed these names straight into their manifest and pass verification.
|
|
17
|
+
*/
|
|
18
|
+
const manifest_js_1 = require("./manifest.js");
|
|
19
|
+
/**
|
|
20
|
+
* Build the namespaced DDL identifier `mod_<module>_<suffix>` for an author's own table.
|
|
21
|
+
*
|
|
22
|
+
* @param moduleName the module's manifest `name` (lowercase slug, `^[a-z][a-z0-9-]*$`).
|
|
23
|
+
* @param suffix the table's local name within the module (lowercase, `[a-z0-9_]+`).
|
|
24
|
+
* @returns the fully-namespaced table name, e.g. `createNamespacedTable('wishlist', 'items')`
|
|
25
|
+
* → `'mod_wishlist_items'`.
|
|
26
|
+
* @throws if `moduleName` is not a valid module slug or `suffix` is empty/invalid.
|
|
27
|
+
*/
|
|
28
|
+
function createNamespacedTable(moduleName, suffix) {
|
|
29
|
+
if (typeof moduleName !== 'string' || !manifest_js_1.MODULE_NAME_RE.test(moduleName)) {
|
|
30
|
+
throw new Error(`createNamespacedTable: module name "${String(moduleName)}" must be a lowercase slug`);
|
|
31
|
+
}
|
|
32
|
+
if (typeof suffix !== 'string' || !manifest_js_1.TABLE_SUFFIX_RE.test(suffix)) {
|
|
33
|
+
throw new Error(`createNamespacedTable: table suffix "${String(suffix)}" must be lowercase [a-z0-9_]`);
|
|
34
|
+
}
|
|
35
|
+
// Defence in depth: reject a suffix that would re-introduce the prefix or escape the namespace.
|
|
36
|
+
if (suffix.startsWith('mod_')) {
|
|
37
|
+
throw new Error(`createNamespacedTable: table suffix "${suffix}" must not start with the reserved "mod_" prefix`);
|
|
38
|
+
}
|
|
39
|
+
return `mod_${moduleName}_${suffix}`;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../src/tables.ts"],"names":[],"mappings":";;AAyBA,sDAkBC;AA3CD;;;;;;;;;;;;;GAaG;AACH,+CAAgE;AAEhE;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,UAAkB,EAAE,MAAc;IACtE,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,4BAAc,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CACb,uCAAuC,MAAM,CAAC,UAAU,CAAC,4BAA4B,CACtF,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,6BAAe,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CACb,wCAAwC,MAAM,CAAC,MAAM,CAAC,+BAA+B,CACtF,CAAC;IACJ,CAAC;IACD,gGAAgG;IAChG,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,wCAAwC,MAAM,kDAAkD,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,UAAU,IAAI,MAAM,EAAE,CAAC;AACvC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sovecom/module-sdk",
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"description": "Public author-facing contract SDK for the SovEcom module ecosystem",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/asifwanders/SovEcom.git",
|
|
9
|
+
"directory": "packages/module-sdk"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/asifwanders/SovEcom#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/asifwanders/SovEcom/issues"
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"require": "./dist/index.js",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"semver": "^7.8.4",
|
|
34
|
+
"zod": "^4.4.3"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^24.0.0",
|
|
38
|
+
"@types/semver": "^7.7.1",
|
|
39
|
+
"typescript": "^5.4.0",
|
|
40
|
+
"vitest": "^4.0.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"lint": "eslint src --ext .ts",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest",
|
|
48
|
+
"clean": "rm -rf dist"
|
|
49
|
+
}
|
|
50
|
+
}
|