@kyro-cms/core 0.9.7 → 0.9.9
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/dist/{WebhookService-BKszZlG0.d.cts → WebhookService-Dj8pJ3sp.d.cts} +1 -1
- package/dist/{WebhookService-Ccf1j-IN.d.ts → WebhookService-DpRB940h.d.ts} +1 -1
- package/dist/api-handler-graphql.cjs +18 -13
- package/dist/api-handler-graphql.cjs.map +1 -1
- package/dist/api-handler-graphql.js +14 -9
- package/dist/api-handler-graphql.js.map +1 -1
- package/dist/api-handler-trpc.cjs +9 -9
- package/dist/api-handler-trpc.js +7 -7
- package/dist/api-handler.cjs +10 -10
- package/dist/api-handler.js +7 -7
- package/dist/{base-CIuXkrH4.d.cts → base-BjyoF6da.d.cts} +2 -2
- package/dist/{base-fFo4lqER.d.ts → base-C2YR8lWt.d.ts} +2 -2
- package/dist/{chunk-NZEUU7QB.js → chunk-3AKCVYDB.js} +4 -109
- package/dist/chunk-3AKCVYDB.js.map +1 -0
- package/dist/{chunk-FKKQUMXR.cjs → chunk-4OCMVGEY.cjs} +4 -110
- package/dist/chunk-4OCMVGEY.cjs.map +1 -0
- package/dist/{chunk-VLK5SJRI.js → chunk-5RFGYEQ3.js} +133 -46
- package/dist/chunk-5RFGYEQ3.js.map +1 -0
- package/dist/chunk-5RPRLTTN.js +861 -0
- package/dist/chunk-5RPRLTTN.js.map +1 -0
- package/dist/{chunk-AX2TZRQJ.js → chunk-BVUDFKKS.js} +16 -3
- package/dist/chunk-BVUDFKKS.js.map +1 -0
- package/dist/{chunk-DRVOUQMT.cjs → chunk-E4JZ73FY.cjs} +54 -79
- package/dist/chunk-E4JZ73FY.cjs.map +1 -0
- package/dist/{chunk-E5UJBLQ7.js → chunk-FIAMXNTH.js} +2 -2
- package/dist/chunk-FIAMXNTH.js.map +1 -0
- package/dist/{chunk-QVJNSAQL.cjs → chunk-IEIHABVR.cjs} +152 -65
- package/dist/chunk-IEIHABVR.cjs.map +1 -0
- package/dist/{chunk-QFLB4EIJ.cjs → chunk-LNTFRAHF.cjs} +118 -9
- package/dist/chunk-LNTFRAHF.cjs.map +1 -0
- package/dist/chunk-N4GN6Q3V.cjs +869 -0
- package/dist/chunk-N4GN6Q3V.cjs.map +1 -0
- package/dist/{chunk-FSKONGCX.cjs → chunk-OJ2AM75W.cjs} +2 -2
- package/dist/chunk-OJ2AM75W.cjs.map +1 -0
- package/dist/{chunk-QX3WNQ7V.js → chunk-OX6GOIPH.js} +4 -4
- package/dist/{chunk-QX3WNQ7V.js.map → chunk-OX6GOIPH.js.map} +1 -1
- package/dist/{chunk-OZ3CCTTA.cjs → chunk-OXYSOU6Z.cjs} +18 -5
- package/dist/chunk-OXYSOU6Z.cjs.map +1 -0
- package/dist/{chunk-CMXVTUYV.js → chunk-OYCICW4B.js} +38 -63
- package/dist/chunk-OYCICW4B.js.map +1 -0
- package/dist/{chunk-HVCUIII2.cjs → chunk-TQG7G7YI.cjs} +13 -13
- package/dist/{chunk-HVCUIII2.cjs.map → chunk-TQG7G7YI.cjs.map} +1 -1
- package/dist/{chunk-3UK5XBVJ.js → chunk-WDTTHKDS.js} +117 -10
- package/dist/chunk-WDTTHKDS.js.map +1 -0
- package/dist/cli/index.cjs +148 -14
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +148 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/client.cjs +3 -3
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/drizzle/index.d.cts +3 -3
- package/dist/drizzle/index.d.ts +3 -3
- package/dist/fields/index.cjs +21 -21
- package/dist/fields/index.d.cts +1 -1
- package/dist/fields/index.d.ts +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/graphql/index.cjs +13 -5
- package/dist/graphql/index.d.cts +37 -7
- package/dist/graphql/index.d.ts +37 -7
- package/dist/graphql/index.js +2 -2
- package/dist/{index-BKta3cBH.d.cts → index-DHbywDs-.d.cts} +2 -2
- package/dist/{index-ClOqnkTO.d.ts → index-jLs0zlft.d.ts} +2 -2
- package/dist/index.cjs +90 -90
- package/dist/index.d.cts +15 -14
- package/dist/index.d.ts +15 -14
- package/dist/index.js +8 -8
- package/dist/mongodb/index.d.cts +3 -3
- package/dist/mongodb/index.d.ts +3 -3
- package/dist/rest/index.cjs +5 -5
- package/dist/rest/index.d.cts +4 -4
- package/dist/rest/index.d.ts +4 -4
- package/dist/rest/index.js +3 -3
- package/dist/templates/index.d.cts +2 -2
- package/dist/templates/index.d.ts +2 -2
- package/dist/trpc/index.cjs +12 -12
- package/dist/trpc/index.d.cts +3 -3
- package/dist/trpc/index.d.ts +3 -3
- package/dist/trpc/index.js +3 -3
- package/dist/{types-Dgzlftb7.d.ts → types-BzH3_rtP.d.ts} +7 -7
- package/dist/{types-Ds0tCA3L.d.cts → types-CY_iNunL.d.cts} +7 -7
- package/dist/{types-DeSApf9T.d.ts → types-C_rVxU2T.d.cts} +4 -4
- package/dist/{types-DeSApf9T.d.cts → types-C_rVxU2T.d.ts} +4 -4
- package/package.json +2 -1
- package/dist/chunk-3UK5XBVJ.js.map +0 -1
- package/dist/chunk-AX2TZRQJ.js.map +0 -1
- package/dist/chunk-CMXVTUYV.js.map +0 -1
- package/dist/chunk-DRVOUQMT.cjs.map +0 -1
- package/dist/chunk-E5UJBLQ7.js.map +0 -1
- package/dist/chunk-FKKQUMXR.cjs.map +0 -1
- package/dist/chunk-FSKONGCX.cjs.map +0 -1
- package/dist/chunk-NZEUU7QB.js.map +0 -1
- package/dist/chunk-OZ3CCTTA.cjs.map +0 -1
- package/dist/chunk-PONTBXR5.js +0 -842
- package/dist/chunk-PONTBXR5.js.map +0 -1
- package/dist/chunk-QFLB4EIJ.cjs.map +0 -1
- package/dist/chunk-QVJNSAQL.cjs.map +0 -1
- package/dist/chunk-RRKCIAPU.cjs +0 -848
- package/dist/chunk-RRKCIAPU.cjs.map +0 -1
- package/dist/chunk-VLK5SJRI.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { createStorageSettingsGlobal } from './chunk-GAOXD3XT.js';
|
|
2
|
-
import { createContext, createKyroServer } from './chunk-
|
|
3
|
-
import { buildGraphQLSchema } from './chunk-
|
|
4
|
-
import { getDefaultRegistry, createHonoApp, createS3Storage, createCloudinaryStorage, createFtpStorage } from './chunk-
|
|
5
|
-
import { createWebhookService, WEBHOOK_COLLECTION, WEBHOOK_DELIVERY_COLLECTION } from './chunk-
|
|
6
|
-
import { API_KEY_COLLECTION, extractApiKeyFromRequest, validateApiKey, createApiKeyContext } from './chunk-
|
|
2
|
+
import { createContext, createKyroServer } from './chunk-OX6GOIPH.js';
|
|
3
|
+
import { buildGraphQLSchema, RelationLoader } from './chunk-5RPRLTTN.js';
|
|
4
|
+
import { getDefaultRegistry, createHonoApp, createS3Storage, createCloudinaryStorage, createFtpStorage } from './chunk-5RFGYEQ3.js';
|
|
5
|
+
import { createWebhookService, WEBHOOK_COLLECTION, WEBHOOK_DELIVERY_COLLECTION } from './chunk-WDTTHKDS.js';
|
|
6
|
+
import { API_KEY_COLLECTION, extractApiKeyFromRequest, validateApiKey, createApiKeyContext } from './chunk-3AKCVYDB.js';
|
|
7
7
|
import { KyroPubSub, createWSServer } from './chunk-BYBMTIMT.js';
|
|
8
|
+
import { DrizzleAdapter } from './chunk-V7KZQIZ6.js';
|
|
9
|
+
import { apiKeys } from './chunk-UUDTPZX6.js';
|
|
8
10
|
import { AbstractBaseAdapter, applyRLS, DEFAULT_RLS_CONFIG, canAccessDocument } from './chunk-WXVB364T.js';
|
|
9
11
|
import { z } from 'zod';
|
|
10
|
-
import {
|
|
12
|
+
import { createYoga } from 'graphql-yoga';
|
|
11
13
|
import { createRequire } from 'module';
|
|
12
14
|
import { randomBytes } from 'crypto';
|
|
13
15
|
|
|
@@ -1553,6 +1555,13 @@ var Kyro = class {
|
|
|
1553
1555
|
]
|
|
1554
1556
|
};
|
|
1555
1557
|
const allGlobals = this.registry.getGlobals();
|
|
1558
|
+
if (this.db instanceof DrizzleAdapter && this.db.dialect === "postgres") {
|
|
1559
|
+
const drizzle = this.db;
|
|
1560
|
+
const tableName = API_KEY_COLLECTION.replace(/-/g, "_");
|
|
1561
|
+
if (!drizzle.schema[tableName]) {
|
|
1562
|
+
drizzle.schema[tableName] = apiKeys;
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1556
1565
|
await this.db.init(
|
|
1557
1566
|
[
|
|
1558
1567
|
...this.registry.getCollections(),
|
|
@@ -1624,78 +1633,41 @@ var Kyro = class {
|
|
|
1624
1633
|
});
|
|
1625
1634
|
}
|
|
1626
1635
|
getGraphQL(options) {
|
|
1627
|
-
const
|
|
1636
|
+
const schema = buildGraphQLSchema({
|
|
1628
1637
|
registry: this.registry,
|
|
1629
1638
|
db: this.db,
|
|
1630
|
-
settings: this.settings
|
|
1631
|
-
user: options?.user,
|
|
1632
|
-
req: options?.req,
|
|
1633
|
-
tenantID: options?.tenantID
|
|
1639
|
+
settings: this.settings
|
|
1634
1640
|
});
|
|
1635
|
-
|
|
1636
|
-
|
|
1641
|
+
const yoga = createYoga({
|
|
1642
|
+
schema,
|
|
1643
|
+
context: async ({ request }) => {
|
|
1637
1644
|
const apiKeyRaw = extractApiKeyFromRequest(request);
|
|
1638
1645
|
let gqlUser;
|
|
1639
1646
|
let apiKeyCtx;
|
|
1640
1647
|
if (apiKeyRaw && this.db) {
|
|
1641
1648
|
const apiKeyResult = await validateApiKey(apiKeyRaw, this.db);
|
|
1642
|
-
if (!apiKeyResult.valid) {
|
|
1643
|
-
return new Response(
|
|
1644
|
-
JSON.stringify({ errors: [{ message: apiKeyResult.error || "Invalid API key" }] }),
|
|
1645
|
-
{ status: 401, headers: { "Content-Type": "application/json" } }
|
|
1646
|
-
);
|
|
1647
|
-
}
|
|
1648
1649
|
if (apiKeyResult.user) {
|
|
1649
1650
|
gqlUser = apiKeyResult.user;
|
|
1650
1651
|
apiKeyCtx = createApiKeyContext(apiKeyResult);
|
|
1651
1652
|
}
|
|
1652
1653
|
}
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
registry: this.registry,
|
|
1654
|
+
const tenantID = options?.tenantID;
|
|
1655
|
+
return {
|
|
1656
1656
|
db: this.db,
|
|
1657
|
-
|
|
1657
|
+
registry: this.registry,
|
|
1658
1658
|
user: gqlUser,
|
|
1659
1659
|
req: request,
|
|
1660
|
-
tenantID
|
|
1661
|
-
apiKey: apiKeyCtx
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
const query = body.query || "";
|
|
1665
|
-
const variables = body.variables || {};
|
|
1666
|
-
if (!query) {
|
|
1667
|
-
return new Response(
|
|
1668
|
-
JSON.stringify({ error: "No GraphQL query provided" }),
|
|
1669
|
-
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
1670
|
-
);
|
|
1671
|
-
}
|
|
1672
|
-
try {
|
|
1673
|
-
const document = parse(query);
|
|
1674
|
-
const result = await execute({
|
|
1675
|
-
schema,
|
|
1676
|
-
document,
|
|
1677
|
-
variableValues: variables,
|
|
1678
|
-
contextValue: {
|
|
1679
|
-
db: this.db,
|
|
1680
|
-
registry: this.registry,
|
|
1681
|
-
settings: this.settings,
|
|
1682
|
-
user: gqlUser,
|
|
1683
|
-
req: request,
|
|
1684
|
-
tenantID: options?.tenantID
|
|
1685
|
-
}
|
|
1686
|
-
});
|
|
1687
|
-
return new Response(JSON.stringify(result), {
|
|
1688
|
-
status: 200,
|
|
1689
|
-
headers: { "Content-Type": "application/json" }
|
|
1690
|
-
});
|
|
1691
|
-
} catch (err) {
|
|
1692
|
-
return new Response(
|
|
1693
|
-
JSON.stringify({ errors: [{ message: err.message }] }),
|
|
1694
|
-
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
1695
|
-
);
|
|
1696
|
-
}
|
|
1660
|
+
tenantID,
|
|
1661
|
+
apiKey: apiKeyCtx,
|
|
1662
|
+
relationLoader: new RelationLoader({ db: this.db, tenantID, user: gqlUser })
|
|
1663
|
+
};
|
|
1697
1664
|
},
|
|
1698
|
-
|
|
1665
|
+
graphiql: false,
|
|
1666
|
+
plugins: []
|
|
1667
|
+
});
|
|
1668
|
+
return {
|
|
1669
|
+
fetch: yoga.fetch,
|
|
1670
|
+
schema
|
|
1699
1671
|
};
|
|
1700
1672
|
}
|
|
1701
1673
|
getTRPC(options) {
|
|
@@ -2290,6 +2262,7 @@ var LocalAdapter = class extends AbstractBaseAdapter {
|
|
|
2290
2262
|
this.db.prepare(
|
|
2291
2263
|
`INSERT OR REPLACE INTO ${tableName} (${quotedColumns.join(", ")}) VALUES (${placeholders})`
|
|
2292
2264
|
).run(...values);
|
|
2265
|
+
this.ensureVersionsTable();
|
|
2293
2266
|
return this.findByID({ collection: slug, id, tenantID, draft: true });
|
|
2294
2267
|
}
|
|
2295
2268
|
async update(args) {
|
|
@@ -2319,6 +2292,7 @@ var LocalAdapter = class extends AbstractBaseAdapter {
|
|
|
2319
2292
|
params.push(tenantID);
|
|
2320
2293
|
}
|
|
2321
2294
|
this.db.prepare(sql).run(...params);
|
|
2295
|
+
this.ensureVersionsTable();
|
|
2322
2296
|
return this.findByID({ collection: slug, id, tenantID, draft: true });
|
|
2323
2297
|
}
|
|
2324
2298
|
async delete(args) {
|
|
@@ -2326,6 +2300,7 @@ var LocalAdapter = class extends AbstractBaseAdapter {
|
|
|
2326
2300
|
const parsed = this.parseGlobalsSlug(slug);
|
|
2327
2301
|
const config = parsed.isGlobal ? this.globals.get(parsed.globalSlug) : this.getCollection(slug);
|
|
2328
2302
|
this.ensureTable(config, parsed.tableName);
|
|
2303
|
+
this.ensureVersionsTable();
|
|
2329
2304
|
const doc = await this.findByID({ collection: slug, id, tenantID, draft: true });
|
|
2330
2305
|
if (!doc) throw new Error(`Document not found: ${slug}/${id}`);
|
|
2331
2306
|
const tableName = parsed.tableName;
|
|
@@ -2762,5 +2737,5 @@ function createLocalAdapter(options) {
|
|
|
2762
2737
|
}
|
|
2763
2738
|
|
|
2764
2739
|
export { ConfigValidationError, Kyro, LocalAdapter, Registry, collectionToCreateZod, collectionToUpdateZod, collectionToWhereZod, collectionToZod, createKyro, createLocalAdapter, createRegistry, fieldToZod, getRegistry, globalToZod, resetRegistry, validateCollection, validateConfig, validateFields, validateGlobal };
|
|
2765
|
-
//# sourceMappingURL=chunk-
|
|
2766
|
-
//# sourceMappingURL=chunk-
|
|
2740
|
+
//# sourceMappingURL=chunk-OYCICW4B.js.map
|
|
2741
|
+
//# sourceMappingURL=chunk-OYCICW4B.js.map
|