@nixxie-cms/core 1.0.3 → 2.0.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/CHANGELOG.md +36 -0
- package/CHANGES-1.1.md +134 -0
- package/context/dist/nixxie-cms-core-context.cjs.js +4 -3
- package/context/dist/nixxie-cms-core-context.esm.js +3 -2
- package/dist/declarations/src/access.d.ts +2 -2
- package/dist/declarations/src/access.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts +2 -2
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/context.d.ts +6 -6
- package/dist/declarations/src/admin-ui/context.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/filters.d.ts +5 -5
- package/dist/declarations/src/admin-ui/utils/filters.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/utils.d.ts +2 -2
- package/dist/declarations/src/admin-ui/utils/utils.d.ts.map +1 -1
- package/dist/declarations/src/context.d.ts +1 -1
- package/dist/declarations/src/context.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bigInt/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bigInt/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bytes/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bytes/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/checkbox/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/checkbox/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/decimal/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/decimal/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/file/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/file/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/float/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/float/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/image/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/image/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/integer/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/integer/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/json/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/json/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/multiselect/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/password/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/password/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/index.d.ts +8 -8
- package/dist/declarations/src/fields/types/relationship/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/select/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/select/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/text/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/text/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/timestamp/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/timestamp/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/virtual/index.d.ts +7 -7
- package/dist/declarations/src/fields/types/virtual/index.d.ts.map +1 -1
- package/dist/declarations/src/helpers.d.ts +249 -13
- package/dist/declarations/src/helpers.d.ts.map +1 -1
- package/dist/declarations/src/index.d.ts +9 -4
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/src/internal-unstable/admin-ui/pages/ListPage/index.d.ts.map +1 -1
- package/dist/declarations/src/lib/admin-meta.d.ts +11 -11
- package/dist/declarations/src/lib/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/access-control.d.ts +18 -18
- package/dist/declarations/src/lib/core/access-control.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/cascade.d.ts +47 -0
- package/dist/declarations/src/lib/core/cascade.d.ts.map +1 -0
- package/dist/declarations/src/lib/core/initialise-lists.d.ts +27 -24
- package/dist/declarations/src/lib/core/initialise-lists.d.ts.map +1 -1
- package/dist/declarations/src/lib/env.d.ts +9 -0
- package/dist/declarations/src/lib/env.d.ts.map +1 -0
- package/dist/declarations/src/lib/system.d.ts +1 -1
- package/dist/declarations/src/lib/system.d.ts.map +1 -1
- package/dist/declarations/src/list-features.d.ts +162 -0
- package/dist/declarations/src/list-features.d.ts.map +1 -0
- package/dist/declarations/src/schema.d.ts +24 -23
- package/dist/declarations/src/schema.d.ts.map +1 -1
- package/dist/declarations/src/session.d.ts +75 -0
- package/dist/declarations/src/session.d.ts.map +1 -1
- package/dist/declarations/src/types/admin-meta.d.ts +11 -11
- package/dist/declarations/src/types/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/types/config/access-control.d.ts +42 -42
- package/dist/declarations/src/types/config/access-control.d.ts.map +1 -1
- package/dist/declarations/src/types/config/fields.d.ts +19 -19
- package/dist/declarations/src/types/config/fields.d.ts.map +1 -1
- package/dist/declarations/src/types/config/hooks.d.ts +131 -131
- package/dist/declarations/src/types/config/hooks.d.ts.map +1 -1
- package/dist/declarations/src/types/config/index.d.ts +190 -8
- package/dist/declarations/src/types/config/index.d.ts.map +1 -1
- package/dist/declarations/src/types/config/lists.d.ts +146 -108
- package/dist/declarations/src/types/config/lists.d.ts.map +1 -1
- package/dist/declarations/src/types/context.d.ts +507 -47
- package/dist/declarations/src/types/context.d.ts.map +1 -1
- package/dist/declarations/src/types/next-fields.d.ts +28 -28
- package/dist/declarations/src/types/next-fields.d.ts.map +1 -1
- package/dist/declarations/src/types/type-info.d.ts +3 -3
- package/dist/declarations/src/types/type-info.d.ts.map +1 -1
- package/dist/{express-455ae20c.cjs.js → express-84d534c2.cjs.js} +6 -6
- package/dist/{express-7559ca2d.esm.js → express-d0a4ce99.esm.js} +6 -6
- package/dist/{index-15c8f81e.esm.js → index-5d8b0b4e.esm.js} +363 -183
- package/dist/index-6055753b.cjs.js +393 -0
- package/dist/{index-42045902.cjs.js → index-ac29f382.cjs.js} +363 -185
- package/dist/index-f1703b7b.esm.js +386 -0
- package/dist/nixxie-cms-core.cjs.js +1388 -30
- package/dist/nixxie-cms-core.esm.js +1362 -24
- package/dist/{non-null-graphql-add6bb3d.cjs.js → non-null-graphql-4a44c122.cjs.js} +1 -1
- package/dist/{non-null-graphql-a84ed64d.esm.js → non-null-graphql-8c5feaae.esm.js} +1 -1
- package/dist/{resolve-hooks-165a9ce2.cjs.js → resolve-hooks-10a5f84c.cjs.js} +240 -6
- package/dist/{resolve-hooks-6813a045.esm.js → resolve-hooks-9e676794.esm.js} +238 -7
- package/dist/{system-a321642d.cjs.js → system-6b37a5f8.cjs.js} +33 -7
- package/dist/{system-03e49e4f.esm.js → system-e591d821.esm.js} +33 -7
- package/fields/dist/nixxie-cms-core-fields.cjs.js +29 -576
- package/fields/dist/nixxie-cms-core-fields.esm.js +18 -565
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.cjs.js +4 -2
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.esm.js +4 -2
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.cjs.js +1 -6
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.esm.js +1 -6
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.cjs.js +4 -2
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.esm.js +4 -2
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.cjs.js +4 -3
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.esm.js +4 -3
- package/package.json +4 -4
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.cjs.js +4 -3
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.esm.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.cjs.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.esm.js +4 -3
- package/session/dist/nixxie-cms-core-session.cjs.js +286 -0
- package/session/dist/nixxie-cms-core-session.esm.js +279 -1
- package/src/access.ts +25 -25
- package/src/admin-ui/admin-meta-graphql.ts +5 -5
- package/src/admin-ui/components/CreateButtonLink.tsx +46 -46
- package/src/admin-ui/components/Navigation.tsx +3 -3
- package/src/admin-ui/context.tsx +6 -6
- package/src/admin-ui/utils/Fields.tsx +241 -241
- package/src/admin-ui/utils/actionData.ts +36 -36
- package/src/admin-ui/utils/filters.ts +148 -148
- package/src/admin-ui/utils/useCreateItem.ts +171 -171
- package/src/admin-ui/utils/utils.tsx +127 -127
- package/src/context.ts +1 -1
- package/src/fields/non-null-graphql.ts +115 -115
- package/src/fields/types/bigInt/index.ts +6 -6
- package/src/fields/types/bytes/index.ts +6 -6
- package/src/fields/types/calendarDay/index.ts +18 -19
- package/src/fields/types/checkbox/index.ts +6 -6
- package/src/fields/types/decimal/index.ts +6 -6
- package/src/fields/types/file/index.ts +8 -8
- package/src/fields/types/float/index.ts +6 -6
- package/src/fields/types/image/index.ts +8 -8
- package/src/fields/types/integer/index.ts +6 -6
- package/src/fields/types/json/index.ts +5 -5
- package/src/fields/types/multiselect/index.ts +7 -7
- package/src/fields/types/multiselect/views/index.tsx +149 -151
- package/src/fields/types/password/index.ts +6 -6
- package/src/fields/types/relationship/index.ts +13 -13
- package/src/fields/types/relationship/views/ComboboxMany.tsx +110 -110
- package/src/fields/types/relationship/views/ComboboxSingle.tsx +115 -115
- package/src/fields/types/relationship/views/ContextualActions.tsx +139 -139
- package/src/fields/types/relationship/views/index.tsx +492 -492
- package/src/fields/types/relationship/views/types.ts +46 -46
- package/src/fields/types/relationship/views/useApolloQuery.ts +185 -185
- package/src/fields/types/relationship/views/useFilter.tsx +109 -109
- package/src/fields/types/select/index.ts +6 -6
- package/src/fields/types/text/index.ts +6 -6
- package/src/fields/types/timestamp/index.ts +23 -21
- package/src/fields/types/virtual/index.ts +11 -11
- package/src/helpers.ts +773 -42
- package/src/index.ts +66 -24
- package/src/internal-unstable/admin-ui/pages/ItemPage/common.tsx +4 -4
- package/src/internal-unstable/admin-ui/pages/ItemPage/index.tsx +5 -5
- package/src/internal-unstable/admin-ui/pages/ListPage/index.tsx +8 -8
- package/src/lib/admin-meta.ts +369 -369
- package/src/lib/context/createContext.ts +6 -0
- package/src/lib/core/access-control.ts +434 -434
- package/src/lib/core/cascade.ts +236 -0
- package/src/lib/core/initialise-lists.ts +49 -33
- package/src/lib/core/mutations/index.ts +7 -0
- package/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts +145 -145
- package/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts +71 -71
- package/src/lib/core/queries/output-field.ts +178 -178
- package/src/lib/env.ts +50 -0
- package/src/lib/id-field.ts +2 -2
- package/src/lib/system.ts +221 -207
- package/src/lib/typescript-schema-printer.ts +227 -227
- package/src/list-features.ts +476 -0
- package/src/schema.ts +92 -22
- package/src/session.ts +225 -0
- package/src/types/admin-meta.ts +218 -218
- package/src/types/config/access-control.ts +186 -186
- package/src/types/config/fields.ts +96 -96
- package/src/types/config/hooks.ts +529 -529
- package/src/types/config/index.ts +206 -7
- package/src/types/config/lists.ts +606 -565
- package/src/types/context.ts +592 -55
- package/src/types/next-fields.ts +31 -31
- package/src/types/type-info.ts +38 -38
- package/src/types/type-tests.ts +21 -21
|
@@ -5,11 +5,11 @@ var path = require('node:path');
|
|
|
5
5
|
var adminMeta$1 = require('./admin-meta-18d0c276.cjs.js');
|
|
6
6
|
var graphql = require('graphql');
|
|
7
7
|
var schema = require('@graphql-ts/schema');
|
|
8
|
-
var resolveHooks = require('./resolve-hooks-
|
|
8
|
+
var resolveHooks = require('./resolve-hooks-10a5f84c.cjs.js');
|
|
9
9
|
var utils$1 = require('./utils-e74e3527.cjs.js');
|
|
10
10
|
var nextFields = require('./next-fields-49c025ef.cjs.js');
|
|
11
|
-
require('@graphql-ts/extend');
|
|
12
11
|
var utils$2 = require('./utils-1b632a8f.cjs.js');
|
|
12
|
+
require('@graphql-ts/extend');
|
|
13
13
|
var access_dist_nixxieCmsCoreAccess = require('../access/dist/nixxie-cms-core-access.cjs.js');
|
|
14
14
|
var values = require('graphql/execution/values');
|
|
15
15
|
var utils = require('./utils-b031e11c.cjs.js');
|
|
@@ -400,7 +400,7 @@ function createContext({
|
|
|
400
400
|
internal,
|
|
401
401
|
sudo
|
|
402
402
|
}) => {
|
|
403
|
-
var _config$email, _config$jobs, _config$cache, _config$audit, _config$webhooks, _config$rateLimit, _config$health, _config$storage, _config$search, _config$notifications, _config$ai;
|
|
403
|
+
var _config$email, _config$jobs, _config$cache, _config$audit, _config$webhooks, _config$rateLimit, _config$health, _config$storage, _config$search, _config$notifications, _config$ai, _config$aiRag, _config$versioning, _config$workflow, _config$apiKeys, _config$logger, _config$backup;
|
|
404
404
|
const schema = internal ? graphQLSchemas.internal : graphQLSchemas.public;
|
|
405
405
|
const rawGraphQL = async ({
|
|
406
406
|
query,
|
|
@@ -446,7 +446,13 @@ function createContext({
|
|
|
446
446
|
storage: (_config$storage = config.storage) !== null && _config$storage !== void 0 ? _config$storage : null,
|
|
447
447
|
search: (_config$search = config.search) !== null && _config$search !== void 0 ? _config$search : null,
|
|
448
448
|
notifications: (_config$notifications = config.notifications) !== null && _config$notifications !== void 0 ? _config$notifications : null,
|
|
449
|
-
ai: (_config$ai = config.ai) !== null && _config$ai !== void 0 ? _config$ai : null
|
|
449
|
+
ai: (_config$ai = config.ai) !== null && _config$ai !== void 0 ? _config$ai : null,
|
|
450
|
+
aiRag: (_config$aiRag = config.aiRag) !== null && _config$aiRag !== void 0 ? _config$aiRag : null,
|
|
451
|
+
versioning: (_config$versioning = config.versioning) !== null && _config$versioning !== void 0 ? _config$versioning : null,
|
|
452
|
+
workflow: (_config$workflow = config.workflow) !== null && _config$workflow !== void 0 ? _config$workflow : null,
|
|
453
|
+
apiKeys: (_config$apiKeys = config.apiKeys) !== null && _config$apiKeys !== void 0 ? _config$apiKeys : null,
|
|
454
|
+
logger: (_config$logger = config.logger) !== null && _config$logger !== void 0 ? _config$logger : null,
|
|
455
|
+
backup: (_config$backup = config.backup) !== null && _config$backup !== void 0 ? _config$backup : null
|
|
450
456
|
},
|
|
451
457
|
transaction: async (f, opts) => {
|
|
452
458
|
return await prisma.$transaction(async prisma_ => {
|
|
@@ -2093,7 +2099,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2093
2099
|
}
|
|
2094
2100
|
const result = {};
|
|
2095
2101
|
for (const listConfig of Object.values(listsConfig)) {
|
|
2096
|
-
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$hooks, _listConfig$isSinglet;
|
|
2102
|
+
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$cascade, _listConfig$hooks, _listConfig$isSinglet;
|
|
2097
2103
|
const {
|
|
2098
2104
|
listKey
|
|
2099
2105
|
} = listConfig;
|
|
@@ -2181,6 +2187,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2181
2187
|
const names = utils$1.__getNames(listKey, listConfig);
|
|
2182
2188
|
result[listKey] = {
|
|
2183
2189
|
access: parseListAccessControl(listConfig.access),
|
|
2190
|
+
cascade: (_listConfig$cascade = listConfig.cascade) !== null && _listConfig$cascade !== void 0 ? _listConfig$cascade : [],
|
|
2184
2191
|
fields: resultFields,
|
|
2185
2192
|
groups,
|
|
2186
2193
|
actions: [],
|
|
@@ -3383,9 +3390,15 @@ async function deleteSingle__(where, list, context, accessFilters) {
|
|
|
3383
3390
|
hookArgs
|
|
3384
3391
|
});
|
|
3385
3392
|
|
|
3393
|
+
// cascade rules: check `restrict` rules before any side effects
|
|
3394
|
+
await resolveHooks.enforceCascadeRestrictions(list, context, item);
|
|
3395
|
+
|
|
3386
3396
|
// before operation
|
|
3387
3397
|
await runSideEffectOnlyHook(list, 'beforeOperation', hookArgs);
|
|
3388
3398
|
|
|
3399
|
+
// cascade rules: delete / disconnect / soft-delete related records
|
|
3400
|
+
await resolveHooks.runCascade(list, context, item);
|
|
3401
|
+
|
|
3389
3402
|
// operation
|
|
3390
3403
|
const result = await context.prisma[list.listKey].delete({
|
|
3391
3404
|
where: {
|
|
@@ -4262,6 +4275,19 @@ function createSystem(config) {
|
|
|
4262
4275
|
async connect() {
|
|
4263
4276
|
var _config$db$onConnect, _config$db2;
|
|
4264
4277
|
await prismaClient.$connect();
|
|
4278
|
+
// Give database-backed service stores access to the context before anything
|
|
4279
|
+
// else runs (see NixxieInitableService).
|
|
4280
|
+
const sudoContext = context.sudo();
|
|
4281
|
+
for (const [name, service] of Object.entries(context.services)) {
|
|
4282
|
+
if (!service || typeof service.init !== 'function') continue;
|
|
4283
|
+
try {
|
|
4284
|
+
await service.init(sudoContext);
|
|
4285
|
+
} catch (err) {
|
|
4286
|
+
throw new Error(`Failed to initialise the "${name}" service: ${err instanceof Error ? err.message : err}`, {
|
|
4287
|
+
cause: err
|
|
4288
|
+
});
|
|
4289
|
+
}
|
|
4290
|
+
}
|
|
4265
4291
|
await ((_config$db$onConnect = (_config$db2 = config.db).onConnect) === null || _config$db$onConnect === void 0 ? void 0 : _config$db$onConnect.call(_config$db2, context));
|
|
4266
4292
|
},
|
|
4267
4293
|
// TODO: only used by tests, remove in breaking change
|
|
@@ -4273,7 +4299,7 @@ function createSystem(config) {
|
|
|
4273
4299
|
}
|
|
4274
4300
|
};
|
|
4275
4301
|
}
|
|
4276
|
-
function
|
|
4302
|
+
function createNixxieContext(config, PrismaModule) {
|
|
4277
4303
|
const system = createSystem(config);
|
|
4278
4304
|
const {
|
|
4279
4305
|
context
|
|
@@ -4281,7 +4307,7 @@ function getContext(config, PrismaModule) {
|
|
|
4281
4307
|
return context;
|
|
4282
4308
|
}
|
|
4283
4309
|
|
|
4310
|
+
exports.createNixxieContext = createNixxieContext;
|
|
4284
4311
|
exports.createSystem = createSystem;
|
|
4285
4312
|
exports.getBuiltNixxieConfigurationPath = getBuiltNixxieConfigurationPath;
|
|
4286
|
-
exports.getContext = getContext;
|
|
4287
4313
|
exports.withSpan = withSpan;
|
|
@@ -3,11 +3,11 @@ import path from 'node:path';
|
|
|
3
3
|
import { c as createAdminMeta } from './admin-meta-14c60fec.esm.js';
|
|
4
4
|
import { GraphQLScalarType, GraphQLObjectType, Kind, OperationTypeNode, GraphQLSchema, execute, astFromValue, GraphQLNonNull, GraphQLList, parse, validate as validate$1, print, graphql, assertInputObjectType, isInputObjectType, GraphQLString } from 'graphql';
|
|
5
5
|
import { GNonNull, GInputObjectType } from '@graphql-ts/schema';
|
|
6
|
-
import { u as userInputError, e as extensionError,
|
|
6
|
+
import { u as userInputError, e as extensionError, c as accessReturnError, d as accessDeniedError, f as formatKeys, g as filterAccessError, l as limitsExceededError, h as expandVoidHooks, v as validationFailureError, j as enforceCascadeRestrictions, r as runCascade, k as resolverError, n as relationshipError } from './resolve-hooks-9e676794.esm.js';
|
|
7
7
|
import { _ as __getNames } from './utils-ef2cd0f4.esm.js';
|
|
8
8
|
import { g, Q as QueryMode } from './next-fields-9bf04ed8.esm.js';
|
|
9
|
-
import '@graphql-ts/extend';
|
|
10
9
|
import { h as humanize } from './utils-0cc426c8.esm.js';
|
|
10
|
+
import '@graphql-ts/extend';
|
|
11
11
|
import { allowAll } from '../access/dist/nixxie-cms-core-access.esm.js';
|
|
12
12
|
import { getVariableValues } from 'graphql/execution/values';
|
|
13
13
|
import { g as getDBFieldKeyForFieldOnMultiField, w as weakMemoize, a as areArraysEqual, i as isRejected, b as isFulfilled, p as promiseAllRejectWithAllErrors } from './utils-f9556354.esm.js';
|
|
@@ -393,7 +393,7 @@ function createContext({
|
|
|
393
393
|
internal,
|
|
394
394
|
sudo
|
|
395
395
|
}) => {
|
|
396
|
-
var _config$email, _config$jobs, _config$cache, _config$audit, _config$webhooks, _config$rateLimit, _config$health, _config$storage, _config$search, _config$notifications, _config$ai;
|
|
396
|
+
var _config$email, _config$jobs, _config$cache, _config$audit, _config$webhooks, _config$rateLimit, _config$health, _config$storage, _config$search, _config$notifications, _config$ai, _config$aiRag, _config$versioning, _config$workflow, _config$apiKeys, _config$logger, _config$backup;
|
|
397
397
|
const schema = internal ? graphQLSchemas.internal : graphQLSchemas.public;
|
|
398
398
|
const rawGraphQL = async ({
|
|
399
399
|
query,
|
|
@@ -439,7 +439,13 @@ function createContext({
|
|
|
439
439
|
storage: (_config$storage = config.storage) !== null && _config$storage !== void 0 ? _config$storage : null,
|
|
440
440
|
search: (_config$search = config.search) !== null && _config$search !== void 0 ? _config$search : null,
|
|
441
441
|
notifications: (_config$notifications = config.notifications) !== null && _config$notifications !== void 0 ? _config$notifications : null,
|
|
442
|
-
ai: (_config$ai = config.ai) !== null && _config$ai !== void 0 ? _config$ai : null
|
|
442
|
+
ai: (_config$ai = config.ai) !== null && _config$ai !== void 0 ? _config$ai : null,
|
|
443
|
+
aiRag: (_config$aiRag = config.aiRag) !== null && _config$aiRag !== void 0 ? _config$aiRag : null,
|
|
444
|
+
versioning: (_config$versioning = config.versioning) !== null && _config$versioning !== void 0 ? _config$versioning : null,
|
|
445
|
+
workflow: (_config$workflow = config.workflow) !== null && _config$workflow !== void 0 ? _config$workflow : null,
|
|
446
|
+
apiKeys: (_config$apiKeys = config.apiKeys) !== null && _config$apiKeys !== void 0 ? _config$apiKeys : null,
|
|
447
|
+
logger: (_config$logger = config.logger) !== null && _config$logger !== void 0 ? _config$logger : null,
|
|
448
|
+
backup: (_config$backup = config.backup) !== null && _config$backup !== void 0 ? _config$backup : null
|
|
443
449
|
},
|
|
444
450
|
transaction: async (f, opts) => {
|
|
445
451
|
return await prisma.$transaction(async prisma_ => {
|
|
@@ -2086,7 +2092,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2086
2092
|
}
|
|
2087
2093
|
const result = {};
|
|
2088
2094
|
for (const listConfig of Object.values(listsConfig)) {
|
|
2089
|
-
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$hooks, _listConfig$isSinglet;
|
|
2095
|
+
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$cascade, _listConfig$hooks, _listConfig$isSinglet;
|
|
2090
2096
|
const {
|
|
2091
2097
|
listKey
|
|
2092
2098
|
} = listConfig;
|
|
@@ -2174,6 +2180,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2174
2180
|
const names = __getNames(listKey, listConfig);
|
|
2175
2181
|
result[listKey] = {
|
|
2176
2182
|
access: parseListAccessControl(listConfig.access),
|
|
2183
|
+
cascade: (_listConfig$cascade = listConfig.cascade) !== null && _listConfig$cascade !== void 0 ? _listConfig$cascade : [],
|
|
2177
2184
|
fields: resultFields,
|
|
2178
2185
|
groups,
|
|
2179
2186
|
actions: [],
|
|
@@ -3376,9 +3383,15 @@ async function deleteSingle__(where, list, context, accessFilters) {
|
|
|
3376
3383
|
hookArgs
|
|
3377
3384
|
});
|
|
3378
3385
|
|
|
3386
|
+
// cascade rules: check `restrict` rules before any side effects
|
|
3387
|
+
await enforceCascadeRestrictions(list, context, item);
|
|
3388
|
+
|
|
3379
3389
|
// before operation
|
|
3380
3390
|
await runSideEffectOnlyHook(list, 'beforeOperation', hookArgs);
|
|
3381
3391
|
|
|
3392
|
+
// cascade rules: delete / disconnect / soft-delete related records
|
|
3393
|
+
await runCascade(list, context, item);
|
|
3394
|
+
|
|
3382
3395
|
// operation
|
|
3383
3396
|
const result = await context.prisma[list.listKey].delete({
|
|
3384
3397
|
where: {
|
|
@@ -4255,6 +4268,19 @@ function createSystem(config) {
|
|
|
4255
4268
|
async connect() {
|
|
4256
4269
|
var _config$db$onConnect, _config$db2;
|
|
4257
4270
|
await prismaClient.$connect();
|
|
4271
|
+
// Give database-backed service stores access to the context before anything
|
|
4272
|
+
// else runs (see NixxieInitableService).
|
|
4273
|
+
const sudoContext = context.sudo();
|
|
4274
|
+
for (const [name, service] of Object.entries(context.services)) {
|
|
4275
|
+
if (!service || typeof service.init !== 'function') continue;
|
|
4276
|
+
try {
|
|
4277
|
+
await service.init(sudoContext);
|
|
4278
|
+
} catch (err) {
|
|
4279
|
+
throw new Error(`Failed to initialise the "${name}" service: ${err instanceof Error ? err.message : err}`, {
|
|
4280
|
+
cause: err
|
|
4281
|
+
});
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4258
4284
|
await ((_config$db$onConnect = (_config$db2 = config.db).onConnect) === null || _config$db$onConnect === void 0 ? void 0 : _config$db$onConnect.call(_config$db2, context));
|
|
4259
4285
|
},
|
|
4260
4286
|
// TODO: only used by tests, remove in breaking change
|
|
@@ -4266,7 +4292,7 @@ function createSystem(config) {
|
|
|
4266
4292
|
}
|
|
4267
4293
|
};
|
|
4268
4294
|
}
|
|
4269
|
-
function
|
|
4295
|
+
function createNixxieContext(config, PrismaModule) {
|
|
4270
4296
|
const system = createSystem(config);
|
|
4271
4297
|
const {
|
|
4272
4298
|
context
|
|
@@ -4274,4 +4300,4 @@ function getContext(config, PrismaModule) {
|
|
|
4274
4300
|
return context;
|
|
4275
4301
|
}
|
|
4276
4302
|
|
|
4277
|
-
export {
|
|
4303
|
+
export { createSystem as a, createNixxieContext as c, getBuiltNixxieConfigurationPath as g, withSpan as w };
|