@nixxie-cms/core 1.0.3 → 1.1.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/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 +171 -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 +349 -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-7559ca2d.esm.js → express-0abbce07.esm.js} +6 -6
- package/dist/{express-455ae20c.cjs.js → express-7ca6f76a.cjs.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 +1387 -30
- package/dist/nixxie-cms-core.esm.js +1361 -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-03e49e4f.esm.js → system-4d2a2648.esm.js} +32 -7
- package/dist/{system-a321642d.cjs.js → system-69e1a285.cjs.js} +32 -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 +5 -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 +91 -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 +185 -7
- package/src/types/config/lists.ts +606 -565
- package/src/types/context.ts +426 -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
|
@@ -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$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,12 @@ 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
|
+
versioning: (_config$versioning = config.versioning) !== null && _config$versioning !== void 0 ? _config$versioning : null,
|
|
444
|
+
workflow: (_config$workflow = config.workflow) !== null && _config$workflow !== void 0 ? _config$workflow : null,
|
|
445
|
+
apiKeys: (_config$apiKeys = config.apiKeys) !== null && _config$apiKeys !== void 0 ? _config$apiKeys : null,
|
|
446
|
+
logger: (_config$logger = config.logger) !== null && _config$logger !== void 0 ? _config$logger : null,
|
|
447
|
+
backup: (_config$backup = config.backup) !== null && _config$backup !== void 0 ? _config$backup : null
|
|
443
448
|
},
|
|
444
449
|
transaction: async (f, opts) => {
|
|
445
450
|
return await prisma.$transaction(async prisma_ => {
|
|
@@ -2086,7 +2091,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2086
2091
|
}
|
|
2087
2092
|
const result = {};
|
|
2088
2093
|
for (const listConfig of Object.values(listsConfig)) {
|
|
2089
|
-
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$hooks, _listConfig$isSinglet;
|
|
2094
|
+
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$cascade, _listConfig$hooks, _listConfig$isSinglet;
|
|
2090
2095
|
const {
|
|
2091
2096
|
listKey
|
|
2092
2097
|
} = listConfig;
|
|
@@ -2174,6 +2179,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2174
2179
|
const names = __getNames(listKey, listConfig);
|
|
2175
2180
|
result[listKey] = {
|
|
2176
2181
|
access: parseListAccessControl(listConfig.access),
|
|
2182
|
+
cascade: (_listConfig$cascade = listConfig.cascade) !== null && _listConfig$cascade !== void 0 ? _listConfig$cascade : [],
|
|
2177
2183
|
fields: resultFields,
|
|
2178
2184
|
groups,
|
|
2179
2185
|
actions: [],
|
|
@@ -3376,9 +3382,15 @@ async function deleteSingle__(where, list, context, accessFilters) {
|
|
|
3376
3382
|
hookArgs
|
|
3377
3383
|
});
|
|
3378
3384
|
|
|
3385
|
+
// cascade rules: check `restrict` rules before any side effects
|
|
3386
|
+
await enforceCascadeRestrictions(list, context, item);
|
|
3387
|
+
|
|
3379
3388
|
// before operation
|
|
3380
3389
|
await runSideEffectOnlyHook(list, 'beforeOperation', hookArgs);
|
|
3381
3390
|
|
|
3391
|
+
// cascade rules: delete / disconnect / soft-delete related records
|
|
3392
|
+
await runCascade(list, context, item);
|
|
3393
|
+
|
|
3382
3394
|
// operation
|
|
3383
3395
|
const result = await context.prisma[list.listKey].delete({
|
|
3384
3396
|
where: {
|
|
@@ -4255,6 +4267,19 @@ function createSystem(config) {
|
|
|
4255
4267
|
async connect() {
|
|
4256
4268
|
var _config$db$onConnect, _config$db2;
|
|
4257
4269
|
await prismaClient.$connect();
|
|
4270
|
+
// Give database-backed service stores access to the context before anything
|
|
4271
|
+
// else runs (see NixxieInitableService).
|
|
4272
|
+
const sudoContext = context.sudo();
|
|
4273
|
+
for (const [name, service] of Object.entries(context.services)) {
|
|
4274
|
+
if (!service || typeof service.init !== 'function') continue;
|
|
4275
|
+
try {
|
|
4276
|
+
await service.init(sudoContext);
|
|
4277
|
+
} catch (err) {
|
|
4278
|
+
throw new Error(`Failed to initialise the "${name}" service: ${err instanceof Error ? err.message : err}`, {
|
|
4279
|
+
cause: err
|
|
4280
|
+
});
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4258
4283
|
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
4284
|
},
|
|
4260
4285
|
// TODO: only used by tests, remove in breaking change
|
|
@@ -4266,7 +4291,7 @@ function createSystem(config) {
|
|
|
4266
4291
|
}
|
|
4267
4292
|
};
|
|
4268
4293
|
}
|
|
4269
|
-
function
|
|
4294
|
+
function createNixxieContext(config, PrismaModule) {
|
|
4270
4295
|
const system = createSystem(config);
|
|
4271
4296
|
const {
|
|
4272
4297
|
context
|
|
@@ -4274,4 +4299,4 @@ function getContext(config, PrismaModule) {
|
|
|
4274
4299
|
return context;
|
|
4275
4300
|
}
|
|
4276
4301
|
|
|
4277
|
-
export {
|
|
4302
|
+
export { createSystem as a, createNixxieContext as c, getBuiltNixxieConfigurationPath as g, withSpan as w };
|
|
@@ -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$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,12 @@ 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
|
+
versioning: (_config$versioning = config.versioning) !== null && _config$versioning !== void 0 ? _config$versioning : null,
|
|
451
|
+
workflow: (_config$workflow = config.workflow) !== null && _config$workflow !== void 0 ? _config$workflow : null,
|
|
452
|
+
apiKeys: (_config$apiKeys = config.apiKeys) !== null && _config$apiKeys !== void 0 ? _config$apiKeys : null,
|
|
453
|
+
logger: (_config$logger = config.logger) !== null && _config$logger !== void 0 ? _config$logger : null,
|
|
454
|
+
backup: (_config$backup = config.backup) !== null && _config$backup !== void 0 ? _config$backup : null
|
|
450
455
|
},
|
|
451
456
|
transaction: async (f, opts) => {
|
|
452
457
|
return await prisma.$transaction(async prisma_ => {
|
|
@@ -2093,7 +2098,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2093
2098
|
}
|
|
2094
2099
|
const result = {};
|
|
2095
2100
|
for (const listConfig of Object.values(listsConfig)) {
|
|
2096
|
-
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$hooks, _listConfig$isSinglet;
|
|
2101
|
+
var _listConfig$ui$labelF, _listConfig$ui$search, _listConfig$cascade, _listConfig$hooks, _listConfig$isSinglet;
|
|
2097
2102
|
const {
|
|
2098
2103
|
listKey
|
|
2099
2104
|
} = listConfig;
|
|
@@ -2181,6 +2186,7 @@ function getListsWithInitialisedFields(config, listsRef) {
|
|
|
2181
2186
|
const names = utils$1.__getNames(listKey, listConfig);
|
|
2182
2187
|
result[listKey] = {
|
|
2183
2188
|
access: parseListAccessControl(listConfig.access),
|
|
2189
|
+
cascade: (_listConfig$cascade = listConfig.cascade) !== null && _listConfig$cascade !== void 0 ? _listConfig$cascade : [],
|
|
2184
2190
|
fields: resultFields,
|
|
2185
2191
|
groups,
|
|
2186
2192
|
actions: [],
|
|
@@ -3383,9 +3389,15 @@ async function deleteSingle__(where, list, context, accessFilters) {
|
|
|
3383
3389
|
hookArgs
|
|
3384
3390
|
});
|
|
3385
3391
|
|
|
3392
|
+
// cascade rules: check `restrict` rules before any side effects
|
|
3393
|
+
await resolveHooks.enforceCascadeRestrictions(list, context, item);
|
|
3394
|
+
|
|
3386
3395
|
// before operation
|
|
3387
3396
|
await runSideEffectOnlyHook(list, 'beforeOperation', hookArgs);
|
|
3388
3397
|
|
|
3398
|
+
// cascade rules: delete / disconnect / soft-delete related records
|
|
3399
|
+
await resolveHooks.runCascade(list, context, item);
|
|
3400
|
+
|
|
3389
3401
|
// operation
|
|
3390
3402
|
const result = await context.prisma[list.listKey].delete({
|
|
3391
3403
|
where: {
|
|
@@ -4262,6 +4274,19 @@ function createSystem(config) {
|
|
|
4262
4274
|
async connect() {
|
|
4263
4275
|
var _config$db$onConnect, _config$db2;
|
|
4264
4276
|
await prismaClient.$connect();
|
|
4277
|
+
// Give database-backed service stores access to the context before anything
|
|
4278
|
+
// else runs (see NixxieInitableService).
|
|
4279
|
+
const sudoContext = context.sudo();
|
|
4280
|
+
for (const [name, service] of Object.entries(context.services)) {
|
|
4281
|
+
if (!service || typeof service.init !== 'function') continue;
|
|
4282
|
+
try {
|
|
4283
|
+
await service.init(sudoContext);
|
|
4284
|
+
} catch (err) {
|
|
4285
|
+
throw new Error(`Failed to initialise the "${name}" service: ${err instanceof Error ? err.message : err}`, {
|
|
4286
|
+
cause: err
|
|
4287
|
+
});
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4265
4290
|
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
4291
|
},
|
|
4267
4292
|
// TODO: only used by tests, remove in breaking change
|
|
@@ -4273,7 +4298,7 @@ function createSystem(config) {
|
|
|
4273
4298
|
}
|
|
4274
4299
|
};
|
|
4275
4300
|
}
|
|
4276
|
-
function
|
|
4301
|
+
function createNixxieContext(config, PrismaModule) {
|
|
4277
4302
|
const system = createSystem(config);
|
|
4278
4303
|
const {
|
|
4279
4304
|
context
|
|
@@ -4281,7 +4306,7 @@ function getContext(config, PrismaModule) {
|
|
|
4281
4306
|
return context;
|
|
4282
4307
|
}
|
|
4283
4308
|
|
|
4309
|
+
exports.createNixxieContext = createNixxieContext;
|
|
4284
4310
|
exports.createSystem = createSystem;
|
|
4285
4311
|
exports.getBuiltNixxieConfigurationPath = getBuiltNixxieConfigurationPath;
|
|
4286
|
-
exports.getContext = getContext;
|
|
4287
4312
|
exports.withSpan = withSpan;
|