@stardeck-customer-apps/data-store-sdk 0.4.0 → 0.6.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/LICENSE +21 -0
- package/SKILL.md +8 -1
- package/dist/chunk-EWWQPGFI.mjs +662 -0
- package/dist/chunk-FEKROS4B.mjs +66 -0
- package/dist/cli/bin.d.mts +1 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +729 -0
- package/dist/cli/bin.mjs +11 -0
- package/dist/cli/generate-types.d.mts +75 -1
- package/dist/cli/generate-types.d.ts +75 -1
- package/dist/cli/generate-types.js +345 -45
- package/dist/cli/generate-types.mjs +24 -430
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.mjs +8 -63
- package/dist/{types-D2D9kZNF.d.mts → types-P3VlojJ9.d.mts} +1 -1
- package/dist/{types-D2D9kZNF.d.ts → types-P3VlojJ9.d.ts} +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/server/manifest.ts
|
|
2
|
+
var STARDECK_DATA_STORES_ENV = "STARDECK_DATA_STORES";
|
|
3
|
+
function readEnv(key) {
|
|
4
|
+
if (typeof process !== "undefined" && process.env?.[key]) {
|
|
5
|
+
return process.env[key];
|
|
6
|
+
}
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
function dataStoreSlug(name) {
|
|
10
|
+
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
11
|
+
return slug || "store";
|
|
12
|
+
}
|
|
13
|
+
function legacyDataStoreEnvName(name) {
|
|
14
|
+
return name.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
15
|
+
}
|
|
16
|
+
function readDataStoreManifest() {
|
|
17
|
+
const raw = readEnv(STARDECK_DATA_STORES_ENV);
|
|
18
|
+
if (!raw) return [];
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse(raw);
|
|
21
|
+
if (!Array.isArray(parsed)) return [];
|
|
22
|
+
return parsed.filter((e) => {
|
|
23
|
+
if (typeof e !== "object" || e === null) return false;
|
|
24
|
+
const entry = e;
|
|
25
|
+
if (typeof entry.id !== "string" || typeof entry.name !== "string" || typeof entry.slug !== "string") {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return entry.storeType === "storage" || typeof entry.url === "string";
|
|
29
|
+
});
|
|
30
|
+
} catch {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function resolveDataStore(ref) {
|
|
35
|
+
return resolveManifestEntry(readDataStoreManifest(), ref);
|
|
36
|
+
}
|
|
37
|
+
function resolveManifestEntry(entries, ref) {
|
|
38
|
+
if (ref.storeId) {
|
|
39
|
+
const byId = entries.find((e) => e.id === ref.storeId);
|
|
40
|
+
if (byId) return byId;
|
|
41
|
+
}
|
|
42
|
+
if (ref.storeName) {
|
|
43
|
+
const target = ref.storeName;
|
|
44
|
+
const byBindingKey = entries.find((e) => e.bindingKey === target);
|
|
45
|
+
if (byBindingKey) return byBindingKey;
|
|
46
|
+
const exact = entries.find((e) => e.slug === target || e.id === target || e.name === target);
|
|
47
|
+
if (exact) return exact;
|
|
48
|
+
const norm = dataStoreSlug(target);
|
|
49
|
+
const byBindingKeyNorm = entries.find((e) => e.bindingKey === norm);
|
|
50
|
+
if (byBindingKeyNorm) return byBindingKeyNorm;
|
|
51
|
+
return entries.find(
|
|
52
|
+
(e) => e.slug === norm || typeof e.name === "string" && dataStoreSlug(e.name) === norm
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
function listDataStores() {
|
|
58
|
+
return readDataStoreManifest();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
legacyDataStoreEnvName,
|
|
63
|
+
readDataStoreManifest,
|
|
64
|
+
resolveDataStore,
|
|
65
|
+
listDataStores
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|