@api-client/core 0.19.42 → 0.20.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/build/src/index.d.ts +1 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +4 -0
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/RuntimeApiModel.d.ts +5 -0
- package/build/src/modeling/RuntimeApiModel.d.ts.map +1 -1
- package/build/src/modeling/RuntimeApiModel.js +25 -0
- package/build/src/modeling/RuntimeApiModel.js.map +1 -1
- package/build/src/modeling/helpers/runtime.d.ts +5 -0
- package/build/src/modeling/helpers/runtime.d.ts.map +1 -0
- package/build/src/modeling/helpers/runtime.js +12 -0
- package/build/src/modeling/helpers/runtime.js.map +1 -0
- package/build/src/modeling/types.d.ts +3 -4
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/modeling/validation/api_model_rules.js +1 -1
- package/build/src/modeling/validation/api_model_rules.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/modeling/RuntimeApiModel.ts +28 -0
- package/src/modeling/helpers/runtime.ts +12 -0
- package/src/modeling/types.ts +3 -4
- package/src/modeling/validation/api_model_rules.ts +1 -1
- package/tests/unit/modeling/RuntimeApiModel.spec.ts +58 -0
- package/tests/unit/modeling/api_model.spec.ts +6 -6
- package/tests/unit/modeling/generators/OasGenerator.spec.ts +1 -1
- package/tests/unit/modeling/helpers/runtime.spec.ts +48 -0
- package/tests/unit/modeling/validation/api_model_rules.spec.ts +2 -2
package/build/src/index.d.ts
CHANGED
|
@@ -47,4 +47,5 @@ export { type IProxyResult, default as ProxyLib } from './proxy/Proxy.js';
|
|
|
47
47
|
export { type IHttpProjectProxyInit, type IHttpProjectStoreProxyInit, default as HttpProjectProxy, } from './proxy/HttpProjectProxy.js';
|
|
48
48
|
export { type IRequestProxyInit, default as RequestProxy } from './proxy/RequestProxy.js';
|
|
49
49
|
export { default as ProxyService } from './proxy/ProxyService.js';
|
|
50
|
+
export { truncateIdentifier } from './modeling/helpers/runtime.js';
|
|
50
51
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKpC,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AAGrC,OAAO,EACL,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,GACnB,MAAM,+BAA+B,CAAA;AAKtC,OAAO,EACL,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,mBAAmB,EACxB,KAAK,SAAS,EACd,KAAK,SAAS,GACf,MAAM,yCAAyC,CAAA;AAChD,cAAc,wBAAwB,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,eAAe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AA;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAC3E,OAAO,EAAE,qBAAqB,EAAE,KAAK,WAAW,EAAE,MAAM,yCAAyC,CAAA;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAC/D,cAAc,qCAAqC,CAAA;AAKnD,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAA;AAKpF,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,qCAAqC,CAAA;AAK5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AAKpC,cAAc,0BAA0B,CAAA;AAKxC,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAKpE,OAAO,EAAE,KAAK,YAAY,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,OAAO,IAAI,gBAAgB,GAC5B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,KAAK,iBAAiB,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACzF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAKjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA"}
|
package/build/src/index.js
CHANGED
|
@@ -82,4 +82,8 @@ export { default as ProxyLib } from './proxy/Proxy.js';
|
|
|
82
82
|
export { default as HttpProjectProxy, } from './proxy/HttpProjectProxy.js';
|
|
83
83
|
export { default as RequestProxy } from './proxy/RequestProxy.js';
|
|
84
84
|
export { default as ProxyService } from './proxy/ProxyService.js';
|
|
85
|
+
//
|
|
86
|
+
// Runtime Database helpers
|
|
87
|
+
//
|
|
88
|
+
export { truncateIdentifier } from './modeling/helpers/runtime.js';
|
|
85
89
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,EAAE;AACF,0BAA0B;AAC1B,EAAE;AACF,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,EAAE;AACF,SAAS;AACT,EAAE;AACF,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AAErC,aAAa;AACb,OAAO,EACL,eAAe,GAOhB,MAAM,+BAA+B,CAAA;AAEtC,EAAE;AACF,OAAO;AACP,EAAE;AACF,OAAO,EACL,iBAAiB,GAOlB,MAAM,yCAAyC,CAAA;AAChD,cAAc,wBAAwB,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,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cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AAEpC,EAAE;AACF,UAAU;AACV,EAAE;AACF,cAAc,0BAA0B,CAAA;AAExC,EAAE;AACF,cAAc;AACd,EAAE;AACF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEpE,EAAE;AACF,cAAc;AACd,EAAE;AACF,OAAO,EAAqB,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAGL,OAAO,IAAI,gBAAgB,GAC5B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAA0B,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACzF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAA","sourcesContent":["// all exports that are save for NodeJS process processing.\n\n//\n// Ecosystem-shared Config\n//\nexport * from './config/index.js'\n\nexport { nanoid } from './nanoid.js'\n\n//\n// Models\n//\nexport * as Models from './models/index.js'\nexport * as Kinds from './models/kinds.js'\nexport * as Modeling from './modeling/index.js'\nexport * as Data from './data/index.js'\nexport * as Patch from './patch/index.js'\nexport * as Authorization from './authorization/index.js'\nexport * as Events from './events/index.js'\nexport * as Exceptions from './exceptions/index.js'\nexport * from './sdk/index.js'\nexport * from './sdk/StoreSdkNode.js'\n\n// Node only.\nexport {\n RuntimeApiModel,\n type RuntimeApiModelSchema,\n type RoutingMap,\n type RouteDefinition,\n type RouteLookup,\n type RuntimeResolvedAction,\n type RuleEvaluator,\n} from './modeling/RuntimeApiModel.js'\n\n//\n// Libs\n//\nexport {\n PayloadSerializer,\n type ISafePayload,\n type IMultipartBody,\n type Payload,\n type DeserializedPayload,\n type IBlobMeta,\n type IFileMeta,\n} from './lib/transformers/PayloadSerializer.js'\nexport * from './lib/logging/index.js'\nexport { Headers } from './lib/headers/Headers.js'\nexport * as EventUtils from './lib/events/Utils.js'\nexport { default as uuidV4 } from './lib/uuid.js'\nexport * as fs from './lib/fs/Fs.js'\nexport { UrlParser } from './lib/parsers/UrlParser.js'\nexport { UrlEncoder } from './lib/parsers/UrlEncoder.js'\nexport * as Timers from './lib/timers/Timers.js'\nexport { UriTemplate, type IUriTemplateOptions } from './lib/parsers/UriTemplate.js'\nexport * from './lib/parsers/UrlProcessor.js'\nexport * as HttpDefinitions from './lib/definitions/HttpDefinitions.js'\nexport * as Buffer from './lib/Buffer.js'\nexport * as Random from './lib/math/Random.js'\nexport * as ColorConverter from './lib/color/ColorConverter.js'\n\n//\n// Cookies\n//\nexport { CookieParser, type SameSiteValue } from './cookies/CookieParser.js'\nexport { CookieJar } from './cookies/CookieJar.js'\nexport { InMemoryCookieJar, clearStore as ClearInMemoryCookieJar } from './cookies/InMemoryCookieJar.js'\n\n//\n// Runtime\n//\nexport { VariablesProcessor } from './runtime/variables/VariablesProcessor.js'\nexport { ProjectRequestRunner } from './runtime/node/ProjectRequestRunner.js'\nexport { HttpRequestRunner } from './runtime/http-runner/HttpRequestRunner.js'\nexport { ProjectSerialRunner } from './runtime/node/ProjectSerialRunner.js'\nexport { ProjectParallelRunner, type IWorkerInfo } from './runtime/node/ProjectParallelRunner.js'\nexport { ProjectRunner } from './runtime/node/ProjectRunner.js'\nexport * from './runtime/node/InteropInterfaces.js'\n\n//\n// Execution reporters\n//\nexport { Reporter } from './runtime/reporters/Reporter.js'\nexport { ProjectRunCliReporter } from './runtime/reporters/ProjectRunCliReporter.js'\n\n//\n// HTTP engine\n//\nexport {\n CoreEngine,\n type HttpEngineOptions,\n type RequestStats,\n type HeadersReceivedDetail,\n type BeforeRedirectDetail,\n type ResponseErrorInit,\n type IRequestAuthState,\n} from './runtime/http-engine/CoreEngine.js'\n\n//\n// Testing\n//\nexport * from './testing/TestCliHelper.js'\nexport * from './testing/getPort.js'\n\n//\n// Mocking\n//\nexport * from './mocking/ProjectMock.js'\n\n//\n// Calculators\n//\nexport { DataCalculator } from './lib/calculators/DataCalculator.js'\n\n//\n// Proxy logic\n//\nexport { type IProxyResult, default as ProxyLib } from './proxy/Proxy.js'\nexport {\n type IHttpProjectProxyInit,\n type IHttpProjectStoreProxyInit,\n default as HttpProjectProxy,\n} from './proxy/HttpProjectProxy.js'\nexport { type IRequestProxyInit, default as RequestProxy } from './proxy/RequestProxy.js'\nexport { default as ProxyService } from './proxy/ProxyService.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,EAAE;AACF,0BAA0B;AAC1B,EAAE;AACF,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,EAAE;AACF,SAAS;AACT,EAAE;AACF,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,aAAa,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AAErC,aAAa;AACb,OAAO,EACL,eAAe,GAOhB,MAAM,+BAA+B,CAAA;AAEtC,EAAE;AACF,OAAO;AACP,EAAE;AACF,OAAO,EACL,iBAAiB,GAOlB,MAAM,yCAAyC,CAAA;AAChD,cAAc,wBAAwB,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACpC,O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E;AACF,UAAU;AACV,EAAE;AACF,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AAEpC,EAAE;AACF,UAAU;AACV,EAAE;AACF,cAAc,0BAA0B,CAAA;AAExC,EAAE;AACF,cAAc;AACd,EAAE;AACF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAA;AAEpE,EAAE;AACF,cAAc;AACd,EAAE;AACF,OAAO,EAAqB,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAGL,OAAO,IAAI,gBAAgB,GAC5B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAA0B,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACzF,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEjE,EAAE;AACF,2BAA2B;AAC3B,EAAE;AACF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA","sourcesContent":["// all exports that are save for NodeJS process processing.\n\n//\n// Ecosystem-shared Config\n//\nexport * from './config/index.js'\n\nexport { nanoid } from './nanoid.js'\n\n//\n// Models\n//\nexport * as Models from './models/index.js'\nexport * as Kinds from './models/kinds.js'\nexport * as Modeling from './modeling/index.js'\nexport * as Data from './data/index.js'\nexport * as Patch from './patch/index.js'\nexport * as Authorization from './authorization/index.js'\nexport * as Events from './events/index.js'\nexport * as Exceptions from './exceptions/index.js'\nexport * from './sdk/index.js'\nexport * from './sdk/StoreSdkNode.js'\n\n// Node only.\nexport {\n RuntimeApiModel,\n type RuntimeApiModelSchema,\n type RoutingMap,\n type RouteDefinition,\n type RouteLookup,\n type RuntimeResolvedAction,\n type RuleEvaluator,\n} from './modeling/RuntimeApiModel.js'\n\n//\n// Libs\n//\nexport {\n PayloadSerializer,\n type ISafePayload,\n type IMultipartBody,\n type Payload,\n type DeserializedPayload,\n type IBlobMeta,\n type IFileMeta,\n} from './lib/transformers/PayloadSerializer.js'\nexport * from './lib/logging/index.js'\nexport { Headers } from './lib/headers/Headers.js'\nexport * as EventUtils from './lib/events/Utils.js'\nexport { default as uuidV4 } from './lib/uuid.js'\nexport * as fs from './lib/fs/Fs.js'\nexport { UrlParser } from './lib/parsers/UrlParser.js'\nexport { UrlEncoder } from './lib/parsers/UrlEncoder.js'\nexport * as Timers from './lib/timers/Timers.js'\nexport { UriTemplate, type IUriTemplateOptions } from './lib/parsers/UriTemplate.js'\nexport * from './lib/parsers/UrlProcessor.js'\nexport * as HttpDefinitions from './lib/definitions/HttpDefinitions.js'\nexport * as Buffer from './lib/Buffer.js'\nexport * as Random from './lib/math/Random.js'\nexport * as ColorConverter from './lib/color/ColorConverter.js'\n\n//\n// Cookies\n//\nexport { CookieParser, type SameSiteValue } from './cookies/CookieParser.js'\nexport { CookieJar } from './cookies/CookieJar.js'\nexport { InMemoryCookieJar, clearStore as ClearInMemoryCookieJar } from './cookies/InMemoryCookieJar.js'\n\n//\n// Runtime\n//\nexport { VariablesProcessor } from './runtime/variables/VariablesProcessor.js'\nexport { ProjectRequestRunner } from './runtime/node/ProjectRequestRunner.js'\nexport { HttpRequestRunner } from './runtime/http-runner/HttpRequestRunner.js'\nexport { ProjectSerialRunner } from './runtime/node/ProjectSerialRunner.js'\nexport { ProjectParallelRunner, type IWorkerInfo } from './runtime/node/ProjectParallelRunner.js'\nexport { ProjectRunner } from './runtime/node/ProjectRunner.js'\nexport * from './runtime/node/InteropInterfaces.js'\n\n//\n// Execution reporters\n//\nexport { Reporter } from './runtime/reporters/Reporter.js'\nexport { ProjectRunCliReporter } from './runtime/reporters/ProjectRunCliReporter.js'\n\n//\n// HTTP engine\n//\nexport {\n CoreEngine,\n type HttpEngineOptions,\n type RequestStats,\n type HeadersReceivedDetail,\n type BeforeRedirectDetail,\n type ResponseErrorInit,\n type IRequestAuthState,\n} from './runtime/http-engine/CoreEngine.js'\n\n//\n// Testing\n//\nexport * from './testing/TestCliHelper.js'\nexport * from './testing/getPort.js'\n\n//\n// Mocking\n//\nexport * from './mocking/ProjectMock.js'\n\n//\n// Calculators\n//\nexport { DataCalculator } from './lib/calculators/DataCalculator.js'\n\n//\n// Proxy logic\n//\nexport { type IProxyResult, default as ProxyLib } from './proxy/Proxy.js'\nexport {\n type IHttpProjectProxyInit,\n type IHttpProjectStoreProxyInit,\n default as HttpProjectProxy,\n} from './proxy/HttpProjectProxy.js'\nexport { type IRequestProxyInit, default as RequestProxy } from './proxy/RequestProxy.js'\nexport { default as ProxyService } from './proxy/ProxyService.js'\n\n//\n// Runtime Database helpers\n//\nexport { truncateIdentifier } from './modeling/helpers/runtime.js'\n"]}
|
|
@@ -56,6 +56,11 @@ export declare class RuntimeApiModel extends ApiModel {
|
|
|
56
56
|
password?: DomainProperty;
|
|
57
57
|
role?: DomainProperty;
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Returns a readonly map of session properties.
|
|
61
|
+
* Note, it creates a copy of the cached map to prevent modification of the internal state.
|
|
62
|
+
*/
|
|
63
|
+
get sessionProperties(): ReadonlyMap<string, DomainProperty>;
|
|
59
64
|
constructor(schema: RuntimeApiModelSchema, domainSchema: DataDomainSchema);
|
|
60
65
|
/**
|
|
61
66
|
* Looks up the corresponding exposed entity and action for a given request.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeApiModel.d.ts","sourceRoot":"","sources":["../../../src/modeling/RuntimeApiModel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB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AAA;CAC/B;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,GAAG,SAAS,CAAA;AAapG;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;;IAY3C;;OAEG;IACH,cAAc,EAAE;QACd,IAAI,CAAC,EAAE,YAAY,CAAA;KACpB,CAAK;IAEN;;OAEG;IACH,gBAAgB,EAAE;QAChB,QAAQ,CAAC,EAAE,cAAc,CAAA;QACzB,QAAQ,CAAC,EAAE,cAAc,CAAA;QACzB,IAAI,CAAC,EAAE,cAAc,CAAA;KACtB,CAAK;IAYN;;;OAGG;IACH,IAAW,iBAAiB,IAAI,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAElE;gBAEW,MAAM,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB;IAoJzE;;;;;;OAMG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAoC7E;;;;;;;;;;;;;;;;OAgBG;IACG,cAAc,CAClB,MAAM,EAAE,qBAAqB,EAC7B,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,OAAO,CAAC;IAwCV,MAAM,IAAI,qBAAqB;CAazC"}
|
|
@@ -2,6 +2,7 @@ import { match, parse, exec } from '@poppinss/matchit';
|
|
|
2
2
|
import { ApiModel } from './ApiModel.js';
|
|
3
3
|
import { SemanticType } from './Semantics.js';
|
|
4
4
|
import { AccessRuleExecutionPhase } from './rules/AccessRule.js';
|
|
5
|
+
import { Exception } from '../exceptions/exception.js';
|
|
5
6
|
/**
|
|
6
7
|
* An optimized API Model subclass designed for fast runtime lookups.
|
|
7
8
|
* It pre-compiles the RoutingMap into a radix tree for O(log N) or faster endpoint resolution.
|
|
@@ -28,6 +29,17 @@ export class RuntimeApiModel extends ApiModel {
|
|
|
28
29
|
* Cached access rules for each action to avoid runtime computation overhead.
|
|
29
30
|
*/
|
|
30
31
|
#actionRulesCache = new WeakMap();
|
|
32
|
+
/**
|
|
33
|
+
* Cached session properties for fast runtime lookup.
|
|
34
|
+
*/
|
|
35
|
+
#sessionProperties = new Map();
|
|
36
|
+
/**
|
|
37
|
+
* Returns a readonly map of session properties.
|
|
38
|
+
* Note, it creates a copy of the cached map to prevent modification of the internal state.
|
|
39
|
+
*/
|
|
40
|
+
get sessionProperties() {
|
|
41
|
+
return new Map(this.#sessionProperties);
|
|
42
|
+
}
|
|
31
43
|
constructor(schema, domainSchema) {
|
|
32
44
|
super(schema, domainSchema);
|
|
33
45
|
if (schema.routingMap) {
|
|
@@ -35,6 +47,19 @@ export class RuntimeApiModel extends ApiModel {
|
|
|
35
47
|
}
|
|
36
48
|
this.#cacheEntitiesAndProperties();
|
|
37
49
|
this.#precomputeAccessRules();
|
|
50
|
+
this.#precomputeSessionProperties();
|
|
51
|
+
}
|
|
52
|
+
#precomputeSessionProperties() {
|
|
53
|
+
if (!this.session || !this.domain) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const prop of this.session.properties) {
|
|
57
|
+
const domainProperty = this.domain.findProperty(prop.key, prop.domain);
|
|
58
|
+
if (!domainProperty) {
|
|
59
|
+
throw new Exception(`Session property ${prop.key} not found in domain`);
|
|
60
|
+
}
|
|
61
|
+
this.#sessionProperties.set(prop.key, domainProperty);
|
|
62
|
+
}
|
|
38
63
|
}
|
|
39
64
|
#precomputeAccessRules() {
|
|
40
65
|
for (const entity of this.exposes.values()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeApiModel.js","sourceRoot":"","sources":["../../../src/modeling/RuntimeApiModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAmB,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAuB,MAAM,eAAe,CAAA;AAK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,MAAM,EAAE,YAAY,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5D,UAAU,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAoB,CAAC,CAAA;QAC7F,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,UAAU;SACX,CAAA;IACH,CAAC;CACF","sourcesContent":["import { match, parse, exec, type RouteToken } from '@poppinss/matchit'\nimport { ApiModel, type ApiModelSchema } from './ApiModel.js'\nimport type { DataDomainSchema } from './DataDomain.js'\nimport type { ActionKind } from './actions/index.js'\nimport type { ExposedEntity } from './ExposedEntity.js'\nimport type { Action } from './actions/Action.js'\nimport { SemanticType } from './Semantics.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { DomainProperty } from './DomainProperty.js'\nimport { AccessRule, AccessRuleExecutionPhase } from './rules/AccessRule.js'\n\n/**\n * Identifies a specific exposed entity and its action kind.\n */\nexport interface RouteLookup {\n exposedEntityKey: string\n actionKind: ActionKind\n}\n\n/**\n * A routing definition mapping a path to an action lookup.\n */\nexport interface RouteDefinition {\n path: string\n lookup: RouteLookup\n}\n\n/**\n * A map of HTTP methods to their route definitions.\n */\nexport type RoutingMap = Record<string, RouteDefinition[]>\n\n/**\n * Schema for an API Model optimized for runtime routing.\n */\nexport interface RuntimeApiModelSchema extends ApiModelSchema {\n routingMap: RoutingMap\n}\n\nexport interface RuntimeResolvedAction {\n entity: ExposedEntity\n action: Action\n params: Record<string, string>\n}\n\nexport type RuleEvaluator = (rule: AccessRule) => Promise<boolean | undefined> | boolean | undefined\n\ninterface PhaseRules {\n permissionRules: AccessRule[]\n mandatoryRules: AccessRule[]\n}\n\ninterface ActionRulesCache {\n preFetch: PhaseRules\n fetch: PhaseRules\n postFetch: PhaseRules\n}\n\n/**\n * An optimized API Model subclass designed for fast runtime lookups.\n * It pre-compiles the RoutingMap into a radix tree for O(log N) or faster endpoint resolution.\n */\nexport class RuntimeApiModel extends ApiModel {\n /**\n * The parsed radix tree for fast routing.\n * Method -> ParsedRoutes\n */\n #routes = new Map<string, RouteToken[][]>()\n\n /**\n * Quick map from matchit parsed route format to our RouteDefinition for returning results\n */\n #definitions = new WeakMap<RouteToken[], RouteDefinition>()\n\n /**\n * Cached references to commonly used entities for fast runtime lookup.\n */\n cachedEntities: {\n user?: DomainEntity\n } = {}\n\n /**\n * Cached references to commonly used properties for fast runtime lookup.\n */\n cachedProperties: {\n username?: DomainProperty\n password?: DomainProperty\n role?: DomainProperty\n } = {}\n\n /**\n * Cached access rules for each action to avoid runtime computation overhead.\n */\n #actionRulesCache = new WeakMap<Action, ActionRulesCache>()\n\n constructor(schema: RuntimeApiModelSchema, domainSchema: DataDomainSchema) {\n super(schema, domainSchema)\n\n if (schema.routingMap) {\n this.#initializeRouter(schema.routingMap)\n }\n\n this.#cacheEntitiesAndProperties()\n this.#precomputeAccessRules()\n }\n\n #precomputeAccessRules(): void {\n for (const entity of this.exposes.values()) {\n for (const action of entity.actions) {\n this.#actionRulesCache.set(action, this.#computeEffectiveRules(action, entity))\n }\n }\n }\n\n #computeEffectiveRules(action: Action, entity: ExposedEntity): ActionRulesCache {\n const hierarchy: AccessRule[][] = []\n\n if (action.accessRule && action.accessRule.length > 0) {\n hierarchy.push(action.accessRule)\n }\n\n let currentEntity: ExposedEntity | undefined = entity\n while (currentEntity) {\n if (currentEntity.accessRule && currentEntity.accessRule.length > 0) {\n hierarchy.push(currentEntity.accessRule)\n }\n currentEntity = currentEntity.parent ? this.exposes.get(currentEntity.parent.key) : undefined\n }\n\n if (this.accessRule && this.accessRule.length > 0) {\n hierarchy.push(this.accessRule)\n }\n\n const result: ActionRulesCache = {\n preFetch: {\n permissionRules: [],\n mandatoryRules: [],\n },\n fetch: {\n permissionRules: [],\n mandatoryRules: [],\n },\n postFetch: {\n permissionRules: [],\n mandatoryRules: [],\n },\n }\n\n const seenTypes = new Set<string>()\n\n for (const rulesLevel of hierarchy) {\n const typesInThisLevel = new Set<string>()\n for (const rule of rulesLevel) {\n const phase = rule.metadata[action.kind as keyof typeof rule.metadata]\n\n // If the rule does not specify an execution phase for this action kind, it is not evaluated\n if (!phase) {\n continue\n }\n\n // Shadowing: If a rule of the same type was defined closer to the action, ignore this one.\n if (seenTypes.has(rule.type)) {\n continue\n }\n typesInThisLevel.add(rule.type)\n\n let bucket\n if (phase === AccessRuleExecutionPhase.POST_FETCH) {\n bucket = result.postFetch\n } else if (phase === AccessRuleExecutionPhase.FETCH) {\n bucket = result.fetch\n } else {\n bucket = result.preFetch\n }\n\n if (rule.mandatory) {\n bucket.mandatoryRules.push(rule)\n } else {\n bucket.permissionRules.push(rule)\n }\n }\n for (const type of typesInThisLevel) {\n seenTypes.add(type)\n }\n }\n\n return result\n }\n\n #cacheEntitiesAndProperties(): void {\n if (!this.user || !this.domain) {\n return\n }\n\n const userEntity = this.domain.findEntity(this.user.key, this.user.domain)\n if (!userEntity) {\n return\n }\n\n this.cachedEntities.user = userEntity\n\n for (const prop of userEntity.properties) {\n if (prop.hasSemantic(SemanticType.Username)) {\n this.cachedProperties.username = prop\n }\n if (prop.hasSemantic(SemanticType.Password)) {\n this.cachedProperties.password = prop\n }\n if (prop.hasSemantic(SemanticType.UserRole)) {\n this.cachedProperties.role = prop\n }\n }\n }\n\n #initializeRouter(routingMap: RoutingMap): void {\n for (const [method, definitions] of Object.entries(routingMap)) {\n const parsedRoutes = []\n for (const def of definitions) {\n // matchit's parse() transforms a route string into an object representation.\n // It expects `:param` syntax, while our API models use OpenAPI `{param}` syntax.\n const matchitPath = def.path.replace(/\\{([^}]+)\\}/g, ':$1')\n const parsed = parse(matchitPath)\n this.#definitions.set(parsed, def)\n parsedRoutes.push(parsed)\n }\n this.#routes.set(method.toUpperCase(), parsedRoutes)\n }\n }\n\n /**\n * Looks up the corresponding exposed entity and action for a given request.\n *\n * @param method The HTTP method (e.g., 'GET', 'POST').\n * @param path The request path (e.g., '/users/123').\n * @returns An object with the entity, action, and extracted path parameters if a match is found.\n */\n lookupAction(method: string, path: string): RuntimeResolvedAction | undefined {\n const parsedRoutes = this.#routes.get(method.toUpperCase())\n if (!parsedRoutes) {\n return undefined\n }\n\n // `match` returns the matching parsed route (which is an array of segments), or empty array if no match\n const matchedRoute = match(path, parsedRoutes)\n if (!matchedRoute || matchedRoute.length === 0) {\n return undefined\n }\n\n const def = this.#definitions.get(matchedRoute)\n if (!def) {\n return undefined\n }\n\n const params = exec(path, matchedRoute)\n\n const entity = this.exposes.get(def.lookup.exposedEntityKey)\n if (!entity) {\n return undefined\n }\n\n const action = entity.actions.find((a) => a.kind === def.lookup.actionKind)\n if (!action) {\n return undefined\n }\n\n return {\n entity,\n action,\n params,\n }\n }\n\n /**\n * Evaluates access rules for a given action and phase.\n *\n * The evaluation process follows two phases per execution phase (PRE_FETCH, FETCH, POST_FETCH):\n * 1. Mandatory Phase: All rules marked as `mandatory: true` across all levels must return true.\n * If any fail, the request is immediately rejected.\n * 2. Permission Phase: Evaluation follows the hierarchy from most specific to most general:\n * Action -> Endpoint (ExposedEntity) -> API Model.\n * If an explicit allow (true) or deny (false) is hit, evaluation stops and returns the result.\n * If no rules match (all return undefined), the request is rejected by default.\n *\n * @param action The resolved action to evaluate.\n * @param evaluator A callback that evaluates a single rule. Should return true (allow),\n * false (deny), or undefined (no hit).\n * @param phase The execution phase to evaluate.\n * @returns A promise that resolves to true if access is granted, false if denied.\n */\n async evaluateAccess(\n action: RuntimeResolvedAction,\n evaluator: RuleEvaluator,\n phase: AccessRuleExecutionPhase\n ): Promise<boolean> {\n let cachedRules = this.#actionRulesCache.get(action.action)\n if (!cachedRules) {\n // Fallback if somehow action is not cached (e.g. dynamically added after initialization or in tests)\n cachedRules = this.#computeEffectiveRules(action.action, action.entity)\n this.#actionRulesCache.set(action.action, cachedRules)\n }\n\n let rulesForPhase\n if (phase === AccessRuleExecutionPhase.POST_FETCH) {\n rulesForPhase = cachedRules.postFetch\n } else if (phase === AccessRuleExecutionPhase.FETCH) {\n rulesForPhase = cachedRules.fetch\n } else {\n rulesForPhase = cachedRules.preFetch\n }\n\n // Step 1: Mandatory Phase\n for (const rule of rulesForPhase.mandatoryRules) {\n const result = await evaluator(rule)\n if (result !== true) {\n return false // Immediately reject if any mandatory rule fails\n }\n }\n\n // Step 2-4: Permission Phase\n for (const rule of rulesForPhase.permissionRules) {\n const result = await evaluator(rule)\n if (result === true) {\n return true\n }\n if (result === false) {\n return false\n }\n }\n\n // Default: no hit\n return false\n }\n\n override toJSON(): RuntimeApiModelSchema {\n const base = super.toJSON() as RuntimeApiModelSchema\n\n const routingMap: RoutingMap = {}\n for (const [method, parsedRoutes] of this.#routes.entries()) {\n routingMap[method] = parsedRoutes.map((pr) => this.#definitions.get(pr) as RouteDefinition)\n }\n\n return {\n ...base,\n routingMap,\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RuntimeApiModel.js","sourceRoot":"","sources":["../../../src/modeling/RuntimeApiModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAmB,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,QAAQ,EAAuB,MAAM,eAAe,CAAA;AAK7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C,OAAO,EAAc,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAiDtD;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C;;;OAGG;IACH,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAA;IAE3C;;OAEG;IACH,YAAY,GAAG,IAAI,OAAO,EAAiC,CAAA;IAE3D;;OAEG;IACH,cAAc,GAEV,EAAE,CAAA;IAEN;;OAEG;IACH,gBAAgB,GAIZ,EAAE,CAAA;IAEN;;OAEG;IACH,iBA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IAAI,CAAC,CAAA;YACpC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QAED,kBAAkB;QAClB,OAAO,KAAK,CAAA;IACd,CAAC;IAEQ,MAAM;QACb,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAA2B,CAAA;QAEpD,MAAM,UAAU,GAAe,EAAE,CAAA;QACjC,KAAK,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5D,UAAU,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAoB,CAAC,CAAA;QAC7F,CAAC;QAED,OAAO;YACL,GAAG,IAAI;YACP,UAAU;SACX,CAAA;IACH,CAAC;CACF","sourcesContent":["import { match, parse, exec, type RouteToken } from '@poppinss/matchit'\nimport { ApiModel, type ApiModelSchema } from './ApiModel.js'\nimport type { DataDomainSchema } from './DataDomain.js'\nimport type { ActionKind } from './actions/index.js'\nimport type { ExposedEntity } from './ExposedEntity.js'\nimport type { Action } from './actions/Action.js'\nimport { SemanticType } from './Semantics.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { DomainProperty } from './DomainProperty.js'\nimport { AccessRule, AccessRuleExecutionPhase } from './rules/AccessRule.js'\nimport { Exception } from '../exceptions/exception.js'\n\n/**\n * Identifies a specific exposed entity and its action kind.\n */\nexport interface RouteLookup {\n exposedEntityKey: string\n actionKind: ActionKind\n}\n\n/**\n * A routing definition mapping a path to an action lookup.\n */\nexport interface RouteDefinition {\n path: string\n lookup: RouteLookup\n}\n\n/**\n * A map of HTTP methods to their route definitions.\n */\nexport type RoutingMap = Record<string, RouteDefinition[]>\n\n/**\n * Schema for an API Model optimized for runtime routing.\n */\nexport interface RuntimeApiModelSchema extends ApiModelSchema {\n routingMap: RoutingMap\n}\n\nexport interface RuntimeResolvedAction {\n entity: ExposedEntity\n action: Action\n params: Record<string, string>\n}\n\nexport type RuleEvaluator = (rule: AccessRule) => Promise<boolean | undefined> | boolean | undefined\n\ninterface PhaseRules {\n permissionRules: AccessRule[]\n mandatoryRules: AccessRule[]\n}\n\ninterface ActionRulesCache {\n preFetch: PhaseRules\n fetch: PhaseRules\n postFetch: PhaseRules\n}\n\n/**\n * An optimized API Model subclass designed for fast runtime lookups.\n * It pre-compiles the RoutingMap into a radix tree for O(log N) or faster endpoint resolution.\n */\nexport class RuntimeApiModel extends ApiModel {\n /**\n * The parsed radix tree for fast routing.\n * Method -> ParsedRoutes\n */\n #routes = new Map<string, RouteToken[][]>()\n\n /**\n * Quick map from matchit parsed route format to our RouteDefinition for returning results\n */\n #definitions = new WeakMap<RouteToken[], RouteDefinition>()\n\n /**\n * Cached references to commonly used entities for fast runtime lookup.\n */\n cachedEntities: {\n user?: DomainEntity\n } = {}\n\n /**\n * Cached references to commonly used properties for fast runtime lookup.\n */\n cachedProperties: {\n username?: DomainProperty\n password?: DomainProperty\n role?: DomainProperty\n } = {}\n\n /**\n * Cached access rules for each action to avoid runtime computation overhead.\n */\n #actionRulesCache = new WeakMap<Action, ActionRulesCache>()\n\n /**\n * Cached session properties for fast runtime lookup.\n */\n readonly #sessionProperties = new Map<string, DomainProperty>()\n\n /**\n * Returns a readonly map of session properties.\n * Note, it creates a copy of the cached map to prevent modification of the internal state.\n */\n public get sessionProperties(): ReadonlyMap<string, DomainProperty> {\n return new Map(this.#sessionProperties)\n }\n\n constructor(schema: RuntimeApiModelSchema, domainSchema: DataDomainSchema) {\n super(schema, domainSchema)\n\n if (schema.routingMap) {\n this.#initializeRouter(schema.routingMap)\n }\n\n this.#cacheEntitiesAndProperties()\n this.#precomputeAccessRules()\n this.#precomputeSessionProperties()\n }\n\n #precomputeSessionProperties(): void {\n if (!this.session || !this.domain) {\n return\n }\n for (const prop of this.session.properties) {\n const domainProperty = this.domain.findProperty(prop.key, prop.domain)\n if (!domainProperty) {\n throw new Exception(`Session property ${prop.key} not found in domain`)\n }\n this.#sessionProperties.set(prop.key, domainProperty)\n }\n }\n\n #precomputeAccessRules(): void {\n for (const entity of this.exposes.values()) {\n for (const action of entity.actions) {\n this.#actionRulesCache.set(action, this.#computeEffectiveRules(action, entity))\n }\n }\n }\n\n #computeEffectiveRules(action: Action, entity: ExposedEntity): ActionRulesCache {\n const hierarchy: AccessRule[][] = []\n\n if (action.accessRule && action.accessRule.length > 0) {\n hierarchy.push(action.accessRule)\n }\n\n let currentEntity: ExposedEntity | undefined = entity\n while (currentEntity) {\n if (currentEntity.accessRule && currentEntity.accessRule.length > 0) {\n hierarchy.push(currentEntity.accessRule)\n }\n currentEntity = currentEntity.parent ? this.exposes.get(currentEntity.parent.key) : undefined\n }\n\n if (this.accessRule && this.accessRule.length > 0) {\n hierarchy.push(this.accessRule)\n }\n\n const result: ActionRulesCache = {\n preFetch: {\n permissionRules: [],\n mandatoryRules: [],\n },\n fetch: {\n permissionRules: [],\n mandatoryRules: [],\n },\n postFetch: {\n permissionRules: [],\n mandatoryRules: [],\n },\n }\n\n const seenTypes = new Set<string>()\n\n for (const rulesLevel of hierarchy) {\n const typesInThisLevel = new Set<string>()\n for (const rule of rulesLevel) {\n const phase = rule.metadata[action.kind as keyof typeof rule.metadata]\n\n // If the rule does not specify an execution phase for this action kind, it is not evaluated\n if (!phase) {\n continue\n }\n\n // Shadowing: If a rule of the same type was defined closer to the action, ignore this one.\n if (seenTypes.has(rule.type)) {\n continue\n }\n typesInThisLevel.add(rule.type)\n\n let bucket\n if (phase === AccessRuleExecutionPhase.POST_FETCH) {\n bucket = result.postFetch\n } else if (phase === AccessRuleExecutionPhase.FETCH) {\n bucket = result.fetch\n } else {\n bucket = result.preFetch\n }\n\n if (rule.mandatory) {\n bucket.mandatoryRules.push(rule)\n } else {\n bucket.permissionRules.push(rule)\n }\n }\n for (const type of typesInThisLevel) {\n seenTypes.add(type)\n }\n }\n\n return result\n }\n\n #cacheEntitiesAndProperties(): void {\n if (!this.user || !this.domain) {\n return\n }\n\n const userEntity = this.domain.findEntity(this.user.key, this.user.domain)\n if (!userEntity) {\n return\n }\n\n this.cachedEntities.user = userEntity\n\n for (const prop of userEntity.properties) {\n if (prop.hasSemantic(SemanticType.Username)) {\n this.cachedProperties.username = prop\n }\n if (prop.hasSemantic(SemanticType.Password)) {\n this.cachedProperties.password = prop\n }\n if (prop.hasSemantic(SemanticType.UserRole)) {\n this.cachedProperties.role = prop\n }\n }\n }\n\n #initializeRouter(routingMap: RoutingMap): void {\n for (const [method, definitions] of Object.entries(routingMap)) {\n const parsedRoutes = []\n for (const def of definitions) {\n // matchit's parse() transforms a route string into an object representation.\n // It expects `:param` syntax, while our API models use OpenAPI `{param}` syntax.\n const matchitPath = def.path.replace(/\\{([^}]+)\\}/g, ':$1')\n const parsed = parse(matchitPath)\n this.#definitions.set(parsed, def)\n parsedRoutes.push(parsed)\n }\n this.#routes.set(method.toUpperCase(), parsedRoutes)\n }\n }\n\n /**\n * Looks up the corresponding exposed entity and action for a given request.\n *\n * @param method The HTTP method (e.g., 'GET', 'POST').\n * @param path The request path (e.g., '/users/123').\n * @returns An object with the entity, action, and extracted path parameters if a match is found.\n */\n lookupAction(method: string, path: string): RuntimeResolvedAction | undefined {\n const parsedRoutes = this.#routes.get(method.toUpperCase())\n if (!parsedRoutes) {\n return undefined\n }\n\n // `match` returns the matching parsed route (which is an array of segments), or empty array if no match\n const matchedRoute = match(path, parsedRoutes)\n if (!matchedRoute || matchedRoute.length === 0) {\n return undefined\n }\n\n const def = this.#definitions.get(matchedRoute)\n if (!def) {\n return undefined\n }\n\n const params = exec(path, matchedRoute)\n\n const entity = this.exposes.get(def.lookup.exposedEntityKey)\n if (!entity) {\n return undefined\n }\n\n const action = entity.actions.find((a) => a.kind === def.lookup.actionKind)\n if (!action) {\n return undefined\n }\n\n return {\n entity,\n action,\n params,\n }\n }\n\n /**\n * Evaluates access rules for a given action and phase.\n *\n * The evaluation process follows two phases per execution phase (PRE_FETCH, FETCH, POST_FETCH):\n * 1. Mandatory Phase: All rules marked as `mandatory: true` across all levels must return true.\n * If any fail, the request is immediately rejected.\n * 2. Permission Phase: Evaluation follows the hierarchy from most specific to most general:\n * Action -> Endpoint (ExposedEntity) -> API Model.\n * If an explicit allow (true) or deny (false) is hit, evaluation stops and returns the result.\n * If no rules match (all return undefined), the request is rejected by default.\n *\n * @param action The resolved action to evaluate.\n * @param evaluator A callback that evaluates a single rule. Should return true (allow),\n * false (deny), or undefined (no hit).\n * @param phase The execution phase to evaluate.\n * @returns A promise that resolves to true if access is granted, false if denied.\n */\n async evaluateAccess(\n action: RuntimeResolvedAction,\n evaluator: RuleEvaluator,\n phase: AccessRuleExecutionPhase\n ): Promise<boolean> {\n let cachedRules = this.#actionRulesCache.get(action.action)\n if (!cachedRules) {\n // Fallback if somehow action is not cached (e.g. dynamically added after initialization or in tests)\n cachedRules = this.#computeEffectiveRules(action.action, action.entity)\n this.#actionRulesCache.set(action.action, cachedRules)\n }\n\n let rulesForPhase\n if (phase === AccessRuleExecutionPhase.POST_FETCH) {\n rulesForPhase = cachedRules.postFetch\n } else if (phase === AccessRuleExecutionPhase.FETCH) {\n rulesForPhase = cachedRules.fetch\n } else {\n rulesForPhase = cachedRules.preFetch\n }\n\n // Step 1: Mandatory Phase\n for (const rule of rulesForPhase.mandatoryRules) {\n const result = await evaluator(rule)\n if (result !== true) {\n return false // Immediately reject if any mandatory rule fails\n }\n }\n\n // Step 2-4: Permission Phase\n for (const rule of rulesForPhase.permissionRules) {\n const result = await evaluator(rule)\n if (result === true) {\n return true\n }\n if (result === false) {\n return false\n }\n }\n\n // Default: no hit\n return false\n }\n\n override toJSON(): RuntimeApiModelSchema {\n const base = super.toJSON() as RuntimeApiModelSchema\n\n const routingMap: RoutingMap = {}\n for (const [method, parsedRoutes] of this.#routes.entries()) {\n routingMap[method] = parsedRoutes.map((pr) => this.#definitions.get(pr) as RouteDefinition)\n }\n\n return {\n ...base,\n routingMap,\n }\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/modeling/helpers/runtime.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIvD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Only here all NodeJS runtime helpers are allowed
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
/**
|
|
4
|
+
* Deterministically truncates long PostgreSQL identifiers to the 63-byte limit.
|
|
5
|
+
*/
|
|
6
|
+
export function truncateIdentifier(name) {
|
|
7
|
+
if (name.length <= 63)
|
|
8
|
+
return name;
|
|
9
|
+
const hash = crypto.createHash('md5').update(name).digest('hex').substring(0, 8);
|
|
10
|
+
return `${name.substring(0, 54)}_${hash}`;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../../src/modeling/helpers/runtime.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE;QAAE,OAAO,IAAI,CAAA;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAChF,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAA;AAC3C,CAAC","sourcesContent":["// Only here all NodeJS runtime helpers are allowed\n\nimport crypto from 'node:crypto'\n\n/**\n * Deterministically truncates long PostgreSQL identifiers to the 63-byte limit.\n */\nexport function truncateIdentifier(name: string): string {\n if (name.length <= 63) return name\n const hash = crypto.createHash('md5').update(name).digest('hex').substring(0, 8)\n return `${name.substring(0, 54)}_${hash}`\n}\n"]}
|
|
@@ -318,12 +318,11 @@ export interface SessionConfiguration {
|
|
|
318
318
|
*/
|
|
319
319
|
secret: string;
|
|
320
320
|
/**
|
|
321
|
-
* The properties
|
|
321
|
+
* The properties to be set on the session `User` object.
|
|
322
322
|
* These properties become available in the `request.auth` object at runtime.
|
|
323
|
-
*
|
|
324
|
-
* In practice, these are the ids of the properties in the `User` entity.
|
|
323
|
+
* The properties are coming from the `User` entity (marked by the Semantic model).
|
|
325
324
|
*/
|
|
326
|
-
properties:
|
|
325
|
+
properties: AssociationTarget[];
|
|
327
326
|
/**
|
|
328
327
|
* The cookie-based session transport configuration.
|
|
329
328
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modeling/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,kBAAkB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CAAA;IACf;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;IACtC;;OAEG;IACH,OAAO,EAAE,yBAAyB,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,MAAM,EAAE,sBAAsB,EAAE,CAAA;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;;;;;;;;;;;;;OAgBG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAA;CAChD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modeling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GraphJson } from '@api-client/graph/graph/types.js'\nimport type { Graph } from '@api-client/graph/graph/Graph.js'\nimport type { DomainAssociation } from './DomainAssociation.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { DomainModel } from './DomainModel.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { DomainProperty } from './DomainProperty.js'\nimport type {\n DomainNamespaceKind,\n DomainEntityKind,\n DomainModelKind,\n DomainPropertyKind,\n DomainAssociationKind,\n DataDomainKind,\n ExposedEntityKind,\n} from '../models/kinds.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { AccessRuleSchema } from './rules/AccessRule.js'\nimport { RateLimitingConfigurationSchema } from './rules/RateLimitingConfiguration.js'\nimport { ActionSchema } from './actions/Action.js'\n\nexport interface DataDomainRemoveOptions {\n /**\n * When true, the object will be forcibly removed.\n * The resolution defined in the `ImpactResolution` class will be applied.\n *\n * For example, when removing an entity that is a parent to another entity, it will\n * removed itself as a parent from the child entity.\n *\n * Note, this option should only be used when the DomainImpactAnalysis has been performed\n * and the user was informed of the impact.\n */\n force?: boolean\n}\n\nexport interface DomainGraphEdge {\n /**\n * Indicates that the edge is to or from a foreign domain.\n */\n foreign?: boolean\n /**\n * The key of the foreign domain. Always set with the `foreign` property.\n */\n domain?: string\n /**\n * The type of the edge.\n * - `association` The edge is to an association object.\n * - When coming **from** an entity (the `v` property), that entity owns the association.\n * - When coming **to** an entity (the `w` property), that entity is the target of the association.\n * An association can have multiple targets.\n * - `property` The edge is to a property object. Can only be created between an entity and a property.\n * - The **from** (`v`) is the entity.\n * - The **to** (`w`) is the property.\n * - `parent` The edge is to a parent object.\n * - The **from** (`v`) is the child entity.\n * - The **to** (`w`) is the parent entity.\n */\n type: 'association' | 'property' | 'parent'\n}\n\nexport type DomainGraphNodeType = DomainNamespace | DomainModel | DomainEntity | DomainProperty | DomainAssociation\n\n/**\n * An interface that describes the data domain dependency.\n */\nexport interface ForeignDomainDependency {\n /**\n * The system registered key of the foreign domain.\n */\n key: string\n /**\n * The version of the foreign domain used in this domain.\n */\n version: string\n}\n\nexport interface AssociationTarget {\n /**\n * The key of the target entity.\n */\n key: string\n /**\n * The key of the target data domain.\n * This is only set when the target is in a different data domain.\n */\n domain?: string\n}\n\n/**\n * The list of functions supported for string properties.\n */\nexport type StringFunctions = 'random' | 'uuid-v4'\n/**\n * The list of functions supported for number properties.\n */\nexport type NumberFunctions = 'incremental'\n/**\n * The list of functions supported for date properties.\n */\nexport type DateFunctions = 'now'\n/**\n * The list of functions supported for datetime properties.\n */\nexport type DateTimeFunctions = 'now'\n/**\n * The list of functions supported for time properties.\n */\nexport type TimeFunctions = 'now'\n/**\n * The list of all functions that can be used as default values for properties.\n */\nexport type FunctionValue = StringFunctions | NumberFunctions | DateFunctions | DateTimeFunctions | TimeFunctions\n\n/**\n * Describes the default value set on a property schema.\n */\nexport interface SchemaDefaultValue {\n /**\n * The type of the default value.\n *\n * - `literal` The `value` should be used as-is.\n * - `function` The value represents the name of the function to be used.\n */\n type: 'literal' | 'function'\n /**\n * The actual value type depends on the `type`.\n * It is always a string and it has to be casted to the property's data type.\n */\n value: string | FunctionValue\n}\n\n/**\n * A general schema definition for a property.\n * This is propagated to all bindings (when they support these properties).\n */\nexport interface PropertySchema {\n /**\n * The minimum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMinimum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n minimum?: number\n /**\n * The maximum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMaximum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n maximum?: number\n /**\n * When set, the minimum value is exclusive.\n *\n * - When `false`: value ≥ minimum.\n * - When `true`: value > minimum.\n */\n exclusiveMinimum?: boolean\n /**\n * When set, the exclusiveMaximum value is exclusive.\n *\n * - When `false`: value ≤ maximum.\n * - When `true`: value < minimum.\n */\n exclusiveMaximum?: boolean\n /**\n * The multiplier value for a number scalar.\n *\n * Examples:\n * - if `1` then every integer is allowed\n * - if `2` than every even number is allowed\n * - if `0.5` than every number dividable by `0.5` is allowed\n */\n multipleOf?: number\n /**\n * The enum values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n enum?: string[]\n /**\n * The default value for the property.\n * This is always encoded as a string. The actual type is defined in the `dataType` property.\n */\n defaultValue?: SchemaDefaultValue\n /**\n * The example values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n examples?: string[]\n /**\n * The pattern to use with a string scalar.\n */\n pattern?: string\n}\n\n/**\n * The shortcut type for the data domain graph.\n */\nexport type DataDomainGraph = Graph<unknown, DomainGraphNodeType, DomainGraphEdge>\n/**\n * The serialized version of the data domain graph.\n */\nexport type SerializedGraph = GraphJson<unknown, object, DomainGraphEdge>\n\n/**\n * Represents a standardized, machine-readable error response body\n * as defined by RFC 7807 for HTTP APIs.\n */\nexport interface ProblemDetails {\n /**\n * A URI that identifies the specific problem type. Should resolve to human-readable docs.\n * e.g., \"https://docs.apinow.app/errors/validation-failed\"\n */\n type: string\n\n /**\n * A short, human-readable summary of the problem type.\n * e.g., \"Validation Error\"\n */\n title: string\n\n /**\n * The HTTP status code generated by the origin server for this problem.\n */\n status?: number\n\n /**\n * A human-readable explanation specific to this occurrence of the problem.\n */\n detail?: string\n\n /**\n * A URI that identifies the specific occurrence of the problem.\n * Can be the API request path that caused the error.\n */\n instance: string\n}\n\n/**\n * The set of supported filter operators for the List and search action.\n * These are used in query parameters, e.g., ?price[gte]=100\n *\n * - eq: Equal\n * - neq: Not Equal\n * - in: Value is one of the elements in the provided array\n * - nin: Value is not one of the elements in the provided array\n * - lt: Less Than\n * - lte: Less Than or Equal\n * - gt: Greater Than\n * - gte: Greater Than or Equal\n * - exists: Checks if the field exists\n *\n * Search filters only:\n * - contains: String contains substring / Array contains element (Substring Match)\n * - match: Lexical Match, multi-word queries against long text.\n */\nexport type ResourceFilterOperator =\n | 'eq' // Equal\n | 'neq' // Not equal\n | 'in' // Value is one of the elements in the provided array\n | 'nin' // Value is not one of the elements in the provided array\n | 'lt' // Less than\n | 'lte' // Less than or equal\n | 'gt' // Greater than\n | 'gte' // Greater than or equal\n | 'exists' // Checks if the field exists\n | 'contains' // String contains substring / Array contains element (Substring Match)\n | 'match' // Lexical Match, multi-word queries against long text.\n\n/**\n * The session transport configuration interface.\n * This defines the properties that are common to all session transports.\n */\ninterface SessionTransport {\n /**\n * Whether the session transport is enabled.\n */\n enabled: boolean\n /**\n * The kind of session transport. Each interface defines its own kind.\n */\n kind: string\n}\n\n/**\n * Configuration for cookie-based session transport.\n */\nexport interface CookieConfiguration extends SessionTransport {\n kind: 'cookie'\n /**\n * The lifetime of the cookie session.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"24h\" for 24 hours.\n *\n * @default \"7d\"\n */\n lifetime: string\n /**\n * Whether the cookie can only be accessed by the server.\n * This is a security feature to prevent client-side scripts from accessing the cookie.\n * If set to false, the cookie can be accessed by client-side scripts.\n * @default true\n */\n httpOnly: boolean // Defaults to true\n /**\n * Whether the cookie should only be sent over secure connections (HTTPS).\n * This is a security feature to prevent the cookie from being sent over unencrypted connections.\n * @default true\n */\n secure: boolean\n /**\n * The SameSite attribute of the cookie.\n * This attribute controls whether the cookie is sent with cross-site requests.\n * - 'none' means the cookie is sent with cross-site requests.\n * - 'lax' means the cookie is sent with top-level navigations and will be sent along with GET\n * requests initiated by third-party websites.\n * @default 'none'\n */\n sameSite: 'none' | 'lax'\n /**\n * The name of the cookie.\n * This is the key under which the session data will be stored in the cookie.\n * @default 'as' - 'as' stands for \"api session\"\n */\n name: string\n}\n\n/**\n * Configuration for JWT-based session transport.\n */\nexport interface JwtConfiguration extends SessionTransport {\n kind: 'jwt'\n /**\n * The lifetime of the JWT token.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"15m\" for 15 minutes.\n *\n * @default \"7d\"\n */\n lifetime: string\n}\n\nexport interface SessionConfiguration {\n /**\n * The secret used to sign the JWT and cookies. Should be handled securely.\n * Not visible in the UI after being set.\n */\n secret: string\n /**\n * The properties from the `User` entity to be encoded into the session payload (JWT/cookie).\n * These properties become available in the `request.auth` object at runtime.\n *\n * In practice, these are the ids of the properties in the `User` entity.\n */\n properties: string[]\n /**\n * The cookie-based session transport configuration.\n */\n cookie?: CookieConfiguration\n\n /**\n * The JWT-based session transport configuration.\n */\n jwt?: JwtConfiguration\n}\n\n/**\n * Defines the authorization strategy for the API.\n * It is a base interface that can be extended for different strategies.\n * For MVP, we will start with Roles-Based Access Control (RBAC).\n */\nexport interface AuthorizationConfiguration {\n /**\n * The authorization strategy. For MVP, we will start with RBAC.\n * Post-MVP will include Permission-Based Access Control (PBAC).\n * The strategy determines how users are granted access to resources.\n *\n * - RBAC (Roles-Based Access Control): Users are assigned roles, and permissions are granted to those roles.\n * - PBAC (Permission-Based Access Control): Users are granted permissions directly, allowing for more\n * granular control.\n */\n strategy: string\n}\n\nexport interface RolesBasedAccessControl extends AuthorizationConfiguration {\n strategy: 'RBAC'\n}\n\nexport type AuthorizationStrategy = RolesBasedAccessControl\n\n/**\n * Configures the strategy for authenticating end-users.\n * An API can only support one authentication strategy at a time.\n * This is a base interface that can be extended for different strategies.\n */\nexport interface AuthenticationConfiguration {\n /**\n * The authentication method. For MVP, this is focused on username/password.\n * This can be extended in the future to include 'SSO'.\n */\n strategy: string\n}\n\n/**\n * Configuration for username/password authentication.\n * This is the primary authentication method for the API (MVP).\n */\nexport interface UsernamePasswordConfiguration extends AuthenticationConfiguration {\n strategy: 'UsernamePassword'\n}\n\nexport type AuthenticationStrategy = UsernamePasswordConfiguration\n\n/**\n * Represents a Data Entity from the Data Domain that the API will expose and operate upon.\n */\nexport interface ExposedEntitySchema {\n kind: typeof ExposedEntityKind\n /**\n * The unique identifier for this exposure instance.\n * In the exposure model, we need to uniquely identify each exposure instance, because\n * an entity can be exposed multiple times in different contexts. Consider the following structure:\n *\n * ```\n * /categories/{categoryId}\n * /products/{productId}/categories\n * /products/{productId}/categories/{categoryId}\n * /promotions/{promotionId}/categories\n * /promotions/{promotionId}/categories/{categoryId}\n * ```\n *\n * The `category` entity would be exposed multiple times (as root and nested under products and promotions).\n * We need a way to distinguish between these different exposure instances.\n */\n key: string\n /**\n * A pointer to a Data Entity from the Data Domain.\n */\n entity: AssociationTarget\n /**\n * Indicates whether this exposure has a collection endpoint.\n * A collection endpoint is optional for nested exposures where the association is 1:1\n * and the schema is embedded directly under the parent resource.\n */\n hasCollection: boolean\n /**\n * A path to the collection endpoint for this exposure.\n * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.\n */\n collectionPath?: string\n\n /**\n * A path to the resource endpoint for this exposure.\n * Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.\n */\n resourcePath: string\n\n /**\n * Whether this exposure is a root exposure (top-level collection).\n * If this is set then the `parent` reference must be populated.\n */\n isRoot?: boolean\n\n /**\n * Parent reference when this exposure was created via following an association.\n */\n parent?: ExposeParentRef\n\n /**\n * Expose-time config used to create this exposure (persisted for auditing/UI).\n * This is only populated for the root exposure. All children exposures inherit this config.\n */\n exposeOptions?: ExposeOptions\n\n /**\n * The list of enabled API actions for this exposure (List/Read/Create/etc.)\n */\n actions: ActionSchema[]\n\n /**\n * Optional array of access rules that define the access control policies for this exposure.\n */\n accessRule?: AccessRuleSchema[]\n\n /**\n * Optional configuration for rate limiting for this exposure.\n */\n rateLimiting?: RateLimitingConfigurationSchema\n\n /**\n * When true, generation for this exposure hit configured limits\n */\n truncated?: boolean\n /**\n * Pagination contract for this exposure.\n */\n paginationContract?: PaginationContract\n}\n\n/**\n * Parent reference stored on a nested exposure\n */\nexport interface ExposeParentRef {\n /**\n * The key of the parent exposed entity. This references the `ExposedEntity.key` property.\n */\n key: string\n /**\n * The association from the parent that produced this exposure.\n * A sub-entity must always have a parent association.\n */\n association: AssociationTarget\n /**\n * The numeric depth from the root exposure (root = 0)\n */\n depth?: number\n}\n\n/**\n * Options passed when creating a new exposure\n */\nexport interface ExposeOptions {\n /**\n * Whether to follow associations when creating the exposure.\n * When not set, it only exposes the passed entity.\n */\n followAssociations?: boolean\n /**\n * The maximum depth to follow associations when creating the exposure.\n */\n maxDepth?: number\n}\n\n/**\n * Represents a pagination strategy for API actions that return collections of resources.\n * This is a base interface that can be extended for different pagination strategies.\n */\nexport interface PaginationStrategy {\n /**\n * The kind of pagination strategy. This is used to identify the specific pagination method.\n * For example, 'cursor' for cursor-based pagination or 'offset' for offset-based pagination.\n */\n kind: string\n /**\n * The default page size for the pagination strategy.\n * This is the number of items returned per page when no specific page size is requested.\n */\n defaultLimit?: number\n /**\n * The maximum page size for the pagination strategy.\n * This is the maximum number of items that can be returned per page.\n * The API runtime defined the upper limit to prevent abuse.\n */\n maxLimit?: number\n}\n\n/**\n * Represents the cursor-based pagination strategy.\n */\nexport interface CursorPaginationStrategy extends PaginationStrategy {\n kind: 'cursor'\n}\n\n/**\n * Represents the offset-based pagination strategy.\n */\nexport interface OffsetPaginationStrategy extends PaginationStrategy {\n kind: 'offset'\n}\n\n/**\n * Represents the contract for pagination. Defines which fields can be used for filtering, sorting,\n * and searching.\n */\nexport interface PaginationContract {\n /**\n * The list of fields (property keys) that can be used for filtering.\n */\n filterableFields: string[]\n /**\n * The list of fields (property keys) that can be used for sorting.\n */\n sortableFields: string[]\n /**\n * The list of fields (property keys) that can be used for searching.\n * Note that these properties must be of type string or array of strings.\n */\n searchableFields: string[]\n /**\n * The default sort order for the pagination strategy.\n * This is the sort order that will be used when no sort order is specified.\n */\n defaultSort?: { field: string; direction: 'asc' | 'desc' }[]\n}\n\nexport type DomainImpactKinds =\n | typeof DomainNamespaceKind\n | typeof DomainEntityKind\n | typeof DomainModelKind\n | typeof DomainPropertyKind\n | typeof DomainAssociationKind\n | typeof DataDomainKind\n\n/**\n * The impact analysis report\n */\nexport interface DomainImpactReport {\n /**\n * The key of the impacted data object.\n * This is the key of the object that is being changed.\n */\n key: string\n /**\n * The kind of the impacted data object.\n * This is the kind of the object that is being changed.\n */\n kind: DomainImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: DomainImpactItem[]\n /**\n * Whether it is possible to proceed with the change.\n * If the change is not possible, the reason will be in the impact list.\n */\n canProceed: boolean\n}\n\nexport interface DomainImpactItem {\n /**\n * The key of the impacted data object.\n */\n key: string\n /**\n * The kind of the impacted data object.\n */\n kind: string\n /**\n * The type of the impact.\n *\n * - `delete` - The data object would be deleted.\n */\n type: 'delete' | 'publish'\n /**\n * The impact description.\n * Explains what will happen to the impacted data object.\n * This is a human-readable description of the impact.\n * It should be clear and concise.\n */\n impact: string\n /**\n * The severity of the impact.\n *\n * - `info` - The impact is informational.\n * - `warning` - The impact can potentially cause problems but is not a blocker.\n * - `error` - The impact is a blocker and needs to be resolved before proceeding.\n */\n severity: 'info' | 'warning' | 'error'\n /**\n * The type of the relationship between two impacted objects.\n */\n relationship?: 'child'\n /**\n * The resolution of the conflict if the change will be forced.\n */\n resolution?: string\n /**\n * The optional parent of the impacted data object.\n * For example, if the impacted item is a property, this will be the entity it belongs to.\n */\n parent?: string\n}\n\nexport interface DeserializeOptions {\n /**\n * The mode to use for deserialization.\n */\n mode?: DeserializationMode\n /**\n * The serialized graph to deserialize.\n * This is the JSON representation of the graph.\n */\n json?: SerializedGraph\n /**\n * The list of foreign domains that this domain depends on.\n */\n dependencies?: DataDomain[]\n}\n\n/**\n * Describes the mode for deserializing a domain graph.\n */\nexport type DeserializationMode = 'strict' | 'lenient'\n\n/**\n * Describes an issue found during deserialization.\n */\nexport interface DeserializationIssue {\n /**\n * The type of issue encountered.\n */\n type: 'missing_node' | 'missing_edge' | 'invalid_parent' | 'missing_dependency' | 'malformed_entry' | 'unknown_kind'\n /**\n * The severity of the issue.\n */\n severity: 'error' | 'warning' | 'info'\n /**\n * A human-readable description of the issue.\n */\n message: string\n /**\n * The key of the affected node, edge, or entity if applicable.\n */\n affectedKey?: string\n /**\n * Additional context about the issue.\n */\n context?: Record<string, unknown>\n /**\n * The action taken to handle this issue in lenient mode.\n */\n resolution?: string\n}\n\n/**\n * The result of a deserialization operation.\n */\nexport interface DeserializationResult {\n /**\n * The deserialized graph.\n */\n graph: DataDomainGraph\n /**\n * Issues encountered during deserialization.\n */\n issues: DeserializationIssue[]\n /**\n * Whether the deserialization was successful.\n * This is set to true when a critical failures occurred.\n */\n success: boolean\n}\n\n/**\n * Available node types for search filtering.\n */\nexport type SearchableNodeType =\n | typeof DomainNamespaceKind\n | typeof DomainModelKind\n | typeof DomainEntityKind\n | typeof DomainPropertyKind\n | typeof DomainAssociationKind\n\n/**\n * Search criteria for filtering domain nodes.\n */\nexport interface DomainSearchCriteria {\n /**\n * Text query to search for in name, displayName, and description fields.\n * Can be a string for exact match or RegExp for pattern matching.\n */\n query?: string | RegExp\n\n /**\n * Filter by specific node types. If not provided, all node types are included.\n */\n nodeTypes?: SearchableNodeType[]\n\n /**\n * Whether to include nodes from foreign domains in the search results.\n * Defaults to false.\n */\n includeForeignDomains?: boolean\n\n /**\n * Case-sensitive search when using string query.\n * Defaults to false (case-insensitive).\n */\n caseSensitive?: boolean\n}\n\n/**\n * A search result containing a matching domain node and metadata.\n */\nexport interface DomainSearchResult {\n /**\n * The matching domain node.\n */\n node: DomainGraphNodeType\n\n /**\n * The field(s) that matched the search query.\n */\n matchedFields: ('name' | 'displayName' | 'description')[]\n\n /**\n * The key used to identify this node in the graph.\n */\n key: string\n\n /**\n * Whether this node belongs to a foreign domain.\n */\n isForeign: boolean\n}\n\n/**\n * Contextual information about where the API Model validation issue occurred.\n * This allows the UI to trace back a validation error to a specific module or component.\n */\nexport interface ApiModelValidationContext {\n /**\n * The key of the ApiModel itself.\n */\n apiModelKey: string\n /**\n * The kind of the affected component (e.g., 'ApiModel', 'ExposedEntity', 'Action').\n */\n kind: string\n /**\n * The key of the specific entity or action where the issue occurred.\n * If the error is at the root API model, this might be the ApiModel's key.\n */\n key: string\n /**\n * The specific property being validated, if applicable.\n */\n property?: string\n /**\n * The key of the parent ExposedEntity, if this issue occurred on a nested entity or an action.\n */\n parentExposedEntityKey?: string\n}\n\n/**\n * Represents a single validation issue found within an ApiModel.\n */\nexport interface ApiModelValidationItem {\n /**\n * A unique code identifying the type of validation error. This enables\n * programmatic handling or auto-fixing in the UI (e.g., 'API_MISSING_NAME', 'LIST_ACTION_MISSING_PAGINATION').\n */\n code: string\n /**\n * A human-readable description of the problem.\n */\n message: string\n /**\n * A human-readable suggestion on how to fix the issue.\n */\n suggestion: string\n /**\n * The severity of the validation issue.\n */\n severity: 'error' | 'warning' | 'info'\n /**\n * Contextual information to trace the issue back to its source component.\n */\n context: ApiModelValidationContext\n}\n\n/**\n * The consolidated result of validating an entire ApiModel or a subset of it.\n */\nexport interface ApiModelValidationResult {\n /**\n * A boolean indicating whether the model is structurally sound and ready for publication.\n * Typically true if there are no 'error' severity issues.\n */\n isValid: boolean\n /**\n * The aggregated list of all validation issues found.\n */\n issues: ApiModelValidationItem[]\n}\n\n/**\n * Schema definition for an association.\n *\n * This is used to define how an association is represented in the schema.\n */\nexport interface AssociationSchema {\n /**\n * Whether the target entity should be embedded under the property name.\n * When false, this association is just an information that one entity depend on another.\n * When true, it changes the definition of the schema having this association to\n * add the target schema properties inline with this property.\n *\n * **When true**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": {\n * \"city\": \"example value\",\n * ...\n * }\n * }\n * ```\n *\n * **When false**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": \"the key of the referenced schema\"\n * }\n * ```\n */\n embedded?: boolean\n /**\n * When the association has multiple targets the union type should be\n * set to describe which union this is.\n *\n * Possible values are:\n *\n * - allOf - To validate against `allOf`, the given data must be valid against\n * all of the given sub-schemas. When generating, it's a sum of all properties.\n * - anyOf - To validate against `anyOf`, the given data must be valid against\n * any (one or more) of the given sub-schemas. When generation a schema, it takes first union schema.\n * - oneOf - To validate against `oneOf`, the given data must be valid against\n * exactly one of the given sub-schemas. It behaves the same as `anyOf` when generating a schema\n * - not - The `not` keyword declares that an instance validates if it doesn’t\n * validate against the given sub-schema. It has no use when generating a schema.\n *\n * @default anyOf\n */\n unionType?: 'allOf' | 'anyOf' | 'oneOf' | 'not'\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/modeling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { GraphJson } from '@api-client/graph/graph/types.js'\nimport type { Graph } from '@api-client/graph/graph/Graph.js'\nimport type { DomainAssociation } from './DomainAssociation.js'\nimport type { DomainEntity } from './DomainEntity.js'\nimport type { DomainModel } from './DomainModel.js'\nimport type { DomainNamespace } from './DomainNamespace.js'\nimport type { DomainProperty } from './DomainProperty.js'\nimport type {\n DomainNamespaceKind,\n DomainEntityKind,\n DomainModelKind,\n DomainPropertyKind,\n DomainAssociationKind,\n DataDomainKind,\n ExposedEntityKind,\n} from '../models/kinds.js'\nimport type { DataDomain } from './DataDomain.js'\nimport { AccessRuleSchema } from './rules/AccessRule.js'\nimport { RateLimitingConfigurationSchema } from './rules/RateLimitingConfiguration.js'\nimport { ActionSchema } from './actions/Action.js'\n\nexport interface DataDomainRemoveOptions {\n /**\n * When true, the object will be forcibly removed.\n * The resolution defined in the `ImpactResolution` class will be applied.\n *\n * For example, when removing an entity that is a parent to another entity, it will\n * removed itself as a parent from the child entity.\n *\n * Note, this option should only be used when the DomainImpactAnalysis has been performed\n * and the user was informed of the impact.\n */\n force?: boolean\n}\n\nexport interface DomainGraphEdge {\n /**\n * Indicates that the edge is to or from a foreign domain.\n */\n foreign?: boolean\n /**\n * The key of the foreign domain. Always set with the `foreign` property.\n */\n domain?: string\n /**\n * The type of the edge.\n * - `association` The edge is to an association object.\n * - When coming **from** an entity (the `v` property), that entity owns the association.\n * - When coming **to** an entity (the `w` property), that entity is the target of the association.\n * An association can have multiple targets.\n * - `property` The edge is to a property object. Can only be created between an entity and a property.\n * - The **from** (`v`) is the entity.\n * - The **to** (`w`) is the property.\n * - `parent` The edge is to a parent object.\n * - The **from** (`v`) is the child entity.\n * - The **to** (`w`) is the parent entity.\n */\n type: 'association' | 'property' | 'parent'\n}\n\nexport type DomainGraphNodeType = DomainNamespace | DomainModel | DomainEntity | DomainProperty | DomainAssociation\n\n/**\n * An interface that describes the data domain dependency.\n */\nexport interface ForeignDomainDependency {\n /**\n * The system registered key of the foreign domain.\n */\n key: string\n /**\n * The version of the foreign domain used in this domain.\n */\n version: string\n}\n\nexport interface AssociationTarget {\n /**\n * The key of the target entity.\n */\n key: string\n /**\n * The key of the target data domain.\n * This is only set when the target is in a different data domain.\n */\n domain?: string\n}\n\n/**\n * The list of functions supported for string properties.\n */\nexport type StringFunctions = 'random' | 'uuid-v4'\n/**\n * The list of functions supported for number properties.\n */\nexport type NumberFunctions = 'incremental'\n/**\n * The list of functions supported for date properties.\n */\nexport type DateFunctions = 'now'\n/**\n * The list of functions supported for datetime properties.\n */\nexport type DateTimeFunctions = 'now'\n/**\n * The list of functions supported for time properties.\n */\nexport type TimeFunctions = 'now'\n/**\n * The list of all functions that can be used as default values for properties.\n */\nexport type FunctionValue = StringFunctions | NumberFunctions | DateFunctions | DateTimeFunctions | TimeFunctions\n\n/**\n * Describes the default value set on a property schema.\n */\nexport interface SchemaDefaultValue {\n /**\n * The type of the default value.\n *\n * - `literal` The `value` should be used as-is.\n * - `function` The value represents the name of the function to be used.\n */\n type: 'literal' | 'function'\n /**\n * The actual value type depends on the `type`.\n * It is always a string and it has to be casted to the property's data type.\n */\n value: string | FunctionValue\n}\n\n/**\n * A general schema definition for a property.\n * This is propagated to all bindings (when they support these properties).\n */\nexport interface PropertySchema {\n /**\n * The minimum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMinimum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n minimum?: number\n /**\n * The maximum value of the property.\n *\n * By default it is inclusive value. Use the `exclusiveMaximum` property to make it exclusive.\n *\n * Used with:\n * - string\n * - number\n * - date\n * - time\n * - datetime\n */\n maximum?: number\n /**\n * When set, the minimum value is exclusive.\n *\n * - When `false`: value ≥ minimum.\n * - When `true`: value > minimum.\n */\n exclusiveMinimum?: boolean\n /**\n * When set, the exclusiveMaximum value is exclusive.\n *\n * - When `false`: value ≤ maximum.\n * - When `true`: value < minimum.\n */\n exclusiveMaximum?: boolean\n /**\n * The multiplier value for a number scalar.\n *\n * Examples:\n * - if `1` then every integer is allowed\n * - if `2` than every even number is allowed\n * - if `0.5` than every number dividable by `0.5` is allowed\n */\n multipleOf?: number\n /**\n * The enum values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n enum?: string[]\n /**\n * The default value for the property.\n * This is always encoded as a string. The actual type is defined in the `dataType` property.\n */\n defaultValue?: SchemaDefaultValue\n /**\n * The example values for the property.\n * They are always encoded as strings. The actual type is defined in the `dataType` property.\n */\n examples?: string[]\n /**\n * The pattern to use with a string scalar.\n */\n pattern?: string\n}\n\n/**\n * The shortcut type for the data domain graph.\n */\nexport type DataDomainGraph = Graph<unknown, DomainGraphNodeType, DomainGraphEdge>\n/**\n * The serialized version of the data domain graph.\n */\nexport type SerializedGraph = GraphJson<unknown, object, DomainGraphEdge>\n\n/**\n * Represents a standardized, machine-readable error response body\n * as defined by RFC 7807 for HTTP APIs.\n */\nexport interface ProblemDetails {\n /**\n * A URI that identifies the specific problem type. Should resolve to human-readable docs.\n * e.g., \"https://docs.apinow.app/errors/validation-failed\"\n */\n type: string\n\n /**\n * A short, human-readable summary of the problem type.\n * e.g., \"Validation Error\"\n */\n title: string\n\n /**\n * The HTTP status code generated by the origin server for this problem.\n */\n status?: number\n\n /**\n * A human-readable explanation specific to this occurrence of the problem.\n */\n detail?: string\n\n /**\n * A URI that identifies the specific occurrence of the problem.\n * Can be the API request path that caused the error.\n */\n instance: string\n}\n\n/**\n * The set of supported filter operators for the List and search action.\n * These are used in query parameters, e.g., ?price[gte]=100\n *\n * - eq: Equal\n * - neq: Not Equal\n * - in: Value is one of the elements in the provided array\n * - nin: Value is not one of the elements in the provided array\n * - lt: Less Than\n * - lte: Less Than or Equal\n * - gt: Greater Than\n * - gte: Greater Than or Equal\n * - exists: Checks if the field exists\n *\n * Search filters only:\n * - contains: String contains substring / Array contains element (Substring Match)\n * - match: Lexical Match, multi-word queries against long text.\n */\nexport type ResourceFilterOperator =\n | 'eq' // Equal\n | 'neq' // Not equal\n | 'in' // Value is one of the elements in the provided array\n | 'nin' // Value is not one of the elements in the provided array\n | 'lt' // Less than\n | 'lte' // Less than or equal\n | 'gt' // Greater than\n | 'gte' // Greater than or equal\n | 'exists' // Checks if the field exists\n | 'contains' // String contains substring / Array contains element (Substring Match)\n | 'match' // Lexical Match, multi-word queries against long text.\n\n/**\n * The session transport configuration interface.\n * This defines the properties that are common to all session transports.\n */\ninterface SessionTransport {\n /**\n * Whether the session transport is enabled.\n */\n enabled: boolean\n /**\n * The kind of session transport. Each interface defines its own kind.\n */\n kind: string\n}\n\n/**\n * Configuration for cookie-based session transport.\n */\nexport interface CookieConfiguration extends SessionTransport {\n kind: 'cookie'\n /**\n * The lifetime of the cookie session.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"24h\" for 24 hours.\n *\n * @default \"7d\"\n */\n lifetime: string\n /**\n * Whether the cookie can only be accessed by the server.\n * This is a security feature to prevent client-side scripts from accessing the cookie.\n * If set to false, the cookie can be accessed by client-side scripts.\n * @default true\n */\n httpOnly: boolean // Defaults to true\n /**\n * Whether the cookie should only be sent over secure connections (HTTPS).\n * This is a security feature to prevent the cookie from being sent over unencrypted connections.\n * @default true\n */\n secure: boolean\n /**\n * The SameSite attribute of the cookie.\n * This attribute controls whether the cookie is sent with cross-site requests.\n * - 'none' means the cookie is sent with cross-site requests.\n * - 'lax' means the cookie is sent with top-level navigations and will be sent along with GET\n * requests initiated by third-party websites.\n * @default 'none'\n */\n sameSite: 'none' | 'lax'\n /**\n * The name of the cookie.\n * This is the key under which the session data will be stored in the cookie.\n * @default 'as' - 'as' stands for \"api session\"\n */\n name: string\n}\n\n/**\n * Configuration for JWT-based session transport.\n */\nexport interface JwtConfiguration extends SessionTransport {\n kind: 'jwt'\n /**\n * The lifetime of the JWT token.\n * This is a string representing the duration, e.g., \"7d\" for 7 days or \"15m\" for 15 minutes.\n *\n * @default \"7d\"\n */\n lifetime: string\n}\n\nexport interface SessionConfiguration {\n /**\n * The secret used to sign the JWT and cookies. Should be handled securely.\n * Not visible in the UI after being set.\n */\n secret: string\n /**\n * The properties to be set on the session `User` object.\n * These properties become available in the `request.auth` object at runtime.\n * The properties are coming from the `User` entity (marked by the Semantic model).\n */\n properties: AssociationTarget[]\n /**\n * The cookie-based session transport configuration.\n */\n cookie?: CookieConfiguration\n\n /**\n * The JWT-based session transport configuration.\n */\n jwt?: JwtConfiguration\n}\n\n/**\n * Defines the authorization strategy for the API.\n * It is a base interface that can be extended for different strategies.\n * For MVP, we will start with Roles-Based Access Control (RBAC).\n */\nexport interface AuthorizationConfiguration {\n /**\n * The authorization strategy. For MVP, we will start with RBAC.\n * Post-MVP will include Permission-Based Access Control (PBAC).\n * The strategy determines how users are granted access to resources.\n *\n * - RBAC (Roles-Based Access Control): Users are assigned roles, and permissions are granted to those roles.\n * - PBAC (Permission-Based Access Control): Users are granted permissions directly, allowing for more\n * granular control.\n */\n strategy: string\n}\n\nexport interface RolesBasedAccessControl extends AuthorizationConfiguration {\n strategy: 'RBAC'\n}\n\nexport type AuthorizationStrategy = RolesBasedAccessControl\n\n/**\n * Configures the strategy for authenticating end-users.\n * An API can only support one authentication strategy at a time.\n * This is a base interface that can be extended for different strategies.\n */\nexport interface AuthenticationConfiguration {\n /**\n * The authentication method. For MVP, this is focused on username/password.\n * This can be extended in the future to include 'SSO'.\n */\n strategy: string\n}\n\n/**\n * Configuration for username/password authentication.\n * This is the primary authentication method for the API (MVP).\n */\nexport interface UsernamePasswordConfiguration extends AuthenticationConfiguration {\n strategy: 'UsernamePassword'\n}\n\nexport type AuthenticationStrategy = UsernamePasswordConfiguration\n\n/**\n * Represents a Data Entity from the Data Domain that the API will expose and operate upon.\n */\nexport interface ExposedEntitySchema {\n kind: typeof ExposedEntityKind\n /**\n * The unique identifier for this exposure instance.\n * In the exposure model, we need to uniquely identify each exposure instance, because\n * an entity can be exposed multiple times in different contexts. Consider the following structure:\n *\n * ```\n * /categories/{categoryId}\n * /products/{productId}/categories\n * /products/{productId}/categories/{categoryId}\n * /promotions/{promotionId}/categories\n * /promotions/{promotionId}/categories/{categoryId}\n * ```\n *\n * The `category` entity would be exposed multiple times (as root and nested under products and promotions).\n * We need a way to distinguish between these different exposure instances.\n */\n key: string\n /**\n * A pointer to a Data Entity from the Data Domain.\n */\n entity: AssociationTarget\n /**\n * Indicates whether this exposure has a collection endpoint.\n * A collection endpoint is optional for nested exposures where the association is 1:1\n * and the schema is embedded directly under the parent resource.\n */\n hasCollection: boolean\n /**\n * A path to the collection endpoint for this exposure.\n * Starts with '/'. Not set for 1:1 nested exposures where collection does not exist.\n */\n collectionPath?: string\n\n /**\n * A path to the resource endpoint for this exposure.\n * Starts with '/'. For 1:1 nested exposures the resource path typically does not include an id segment.\n */\n resourcePath: string\n\n /**\n * Whether this exposure is a root exposure (top-level collection).\n * If this is set then the `parent` reference must be populated.\n */\n isRoot?: boolean\n\n /**\n * Parent reference when this exposure was created via following an association.\n */\n parent?: ExposeParentRef\n\n /**\n * Expose-time config used to create this exposure (persisted for auditing/UI).\n * This is only populated for the root exposure. All children exposures inherit this config.\n */\n exposeOptions?: ExposeOptions\n\n /**\n * The list of enabled API actions for this exposure (List/Read/Create/etc.)\n */\n actions: ActionSchema[]\n\n /**\n * Optional array of access rules that define the access control policies for this exposure.\n */\n accessRule?: AccessRuleSchema[]\n\n /**\n * Optional configuration for rate limiting for this exposure.\n */\n rateLimiting?: RateLimitingConfigurationSchema\n\n /**\n * When true, generation for this exposure hit configured limits\n */\n truncated?: boolean\n /**\n * Pagination contract for this exposure.\n */\n paginationContract?: PaginationContract\n}\n\n/**\n * Parent reference stored on a nested exposure\n */\nexport interface ExposeParentRef {\n /**\n * The key of the parent exposed entity. This references the `ExposedEntity.key` property.\n */\n key: string\n /**\n * The association from the parent that produced this exposure.\n * A sub-entity must always have a parent association.\n */\n association: AssociationTarget\n /**\n * The numeric depth from the root exposure (root = 0)\n */\n depth?: number\n}\n\n/**\n * Options passed when creating a new exposure\n */\nexport interface ExposeOptions {\n /**\n * Whether to follow associations when creating the exposure.\n * When not set, it only exposes the passed entity.\n */\n followAssociations?: boolean\n /**\n * The maximum depth to follow associations when creating the exposure.\n */\n maxDepth?: number\n}\n\n/**\n * Represents a pagination strategy for API actions that return collections of resources.\n * This is a base interface that can be extended for different pagination strategies.\n */\nexport interface PaginationStrategy {\n /**\n * The kind of pagination strategy. This is used to identify the specific pagination method.\n * For example, 'cursor' for cursor-based pagination or 'offset' for offset-based pagination.\n */\n kind: string\n /**\n * The default page size for the pagination strategy.\n * This is the number of items returned per page when no specific page size is requested.\n */\n defaultLimit?: number\n /**\n * The maximum page size for the pagination strategy.\n * This is the maximum number of items that can be returned per page.\n * The API runtime defined the upper limit to prevent abuse.\n */\n maxLimit?: number\n}\n\n/**\n * Represents the cursor-based pagination strategy.\n */\nexport interface CursorPaginationStrategy extends PaginationStrategy {\n kind: 'cursor'\n}\n\n/**\n * Represents the offset-based pagination strategy.\n */\nexport interface OffsetPaginationStrategy extends PaginationStrategy {\n kind: 'offset'\n}\n\n/**\n * Represents the contract for pagination. Defines which fields can be used for filtering, sorting,\n * and searching.\n */\nexport interface PaginationContract {\n /**\n * The list of fields (property keys) that can be used for filtering.\n */\n filterableFields: string[]\n /**\n * The list of fields (property keys) that can be used for sorting.\n */\n sortableFields: string[]\n /**\n * The list of fields (property keys) that can be used for searching.\n * Note that these properties must be of type string or array of strings.\n */\n searchableFields: string[]\n /**\n * The default sort order for the pagination strategy.\n * This is the sort order that will be used when no sort order is specified.\n */\n defaultSort?: { field: string; direction: 'asc' | 'desc' }[]\n}\n\nexport type DomainImpactKinds =\n | typeof DomainNamespaceKind\n | typeof DomainEntityKind\n | typeof DomainModelKind\n | typeof DomainPropertyKind\n | typeof DomainAssociationKind\n | typeof DataDomainKind\n\n/**\n * The impact analysis report\n */\nexport interface DomainImpactReport {\n /**\n * The key of the impacted data object.\n * This is the key of the object that is being changed.\n */\n key: string\n /**\n * The kind of the impacted data object.\n * This is the kind of the object that is being changed.\n */\n kind: DomainImpactKinds\n /**\n * The list of impacted data objects.\n */\n impact: DomainImpactItem[]\n /**\n * Whether it is possible to proceed with the change.\n * If the change is not possible, the reason will be in the impact list.\n */\n canProceed: boolean\n}\n\nexport interface DomainImpactItem {\n /**\n * The key of the impacted data object.\n */\n key: string\n /**\n * The kind of the impacted data object.\n */\n kind: string\n /**\n * The type of the impact.\n *\n * - `delete` - The data object would be deleted.\n */\n type: 'delete' | 'publish'\n /**\n * The impact description.\n * Explains what will happen to the impacted data object.\n * This is a human-readable description of the impact.\n * It should be clear and concise.\n */\n impact: string\n /**\n * The severity of the impact.\n *\n * - `info` - The impact is informational.\n * - `warning` - The impact can potentially cause problems but is not a blocker.\n * - `error` - The impact is a blocker and needs to be resolved before proceeding.\n */\n severity: 'info' | 'warning' | 'error'\n /**\n * The type of the relationship between two impacted objects.\n */\n relationship?: 'child'\n /**\n * The resolution of the conflict if the change will be forced.\n */\n resolution?: string\n /**\n * The optional parent of the impacted data object.\n * For example, if the impacted item is a property, this will be the entity it belongs to.\n */\n parent?: string\n}\n\nexport interface DeserializeOptions {\n /**\n * The mode to use for deserialization.\n */\n mode?: DeserializationMode\n /**\n * The serialized graph to deserialize.\n * This is the JSON representation of the graph.\n */\n json?: SerializedGraph\n /**\n * The list of foreign domains that this domain depends on.\n */\n dependencies?: DataDomain[]\n}\n\n/**\n * Describes the mode for deserializing a domain graph.\n */\nexport type DeserializationMode = 'strict' | 'lenient'\n\n/**\n * Describes an issue found during deserialization.\n */\nexport interface DeserializationIssue {\n /**\n * The type of issue encountered.\n */\n type: 'missing_node' | 'missing_edge' | 'invalid_parent' | 'missing_dependency' | 'malformed_entry' | 'unknown_kind'\n /**\n * The severity of the issue.\n */\n severity: 'error' | 'warning' | 'info'\n /**\n * A human-readable description of the issue.\n */\n message: string\n /**\n * The key of the affected node, edge, or entity if applicable.\n */\n affectedKey?: string\n /**\n * Additional context about the issue.\n */\n context?: Record<string, unknown>\n /**\n * The action taken to handle this issue in lenient mode.\n */\n resolution?: string\n}\n\n/**\n * The result of a deserialization operation.\n */\nexport interface DeserializationResult {\n /**\n * The deserialized graph.\n */\n graph: DataDomainGraph\n /**\n * Issues encountered during deserialization.\n */\n issues: DeserializationIssue[]\n /**\n * Whether the deserialization was successful.\n * This is set to true when a critical failures occurred.\n */\n success: boolean\n}\n\n/**\n * Available node types for search filtering.\n */\nexport type SearchableNodeType =\n | typeof DomainNamespaceKind\n | typeof DomainModelKind\n | typeof DomainEntityKind\n | typeof DomainPropertyKind\n | typeof DomainAssociationKind\n\n/**\n * Search criteria for filtering domain nodes.\n */\nexport interface DomainSearchCriteria {\n /**\n * Text query to search for in name, displayName, and description fields.\n * Can be a string for exact match or RegExp for pattern matching.\n */\n query?: string | RegExp\n\n /**\n * Filter by specific node types. If not provided, all node types are included.\n */\n nodeTypes?: SearchableNodeType[]\n\n /**\n * Whether to include nodes from foreign domains in the search results.\n * Defaults to false.\n */\n includeForeignDomains?: boolean\n\n /**\n * Case-sensitive search when using string query.\n * Defaults to false (case-insensitive).\n */\n caseSensitive?: boolean\n}\n\n/**\n * A search result containing a matching domain node and metadata.\n */\nexport interface DomainSearchResult {\n /**\n * The matching domain node.\n */\n node: DomainGraphNodeType\n\n /**\n * The field(s) that matched the search query.\n */\n matchedFields: ('name' | 'displayName' | 'description')[]\n\n /**\n * The key used to identify this node in the graph.\n */\n key: string\n\n /**\n * Whether this node belongs to a foreign domain.\n */\n isForeign: boolean\n}\n\n/**\n * Contextual information about where the API Model validation issue occurred.\n * This allows the UI to trace back a validation error to a specific module or component.\n */\nexport interface ApiModelValidationContext {\n /**\n * The key of the ApiModel itself.\n */\n apiModelKey: string\n /**\n * The kind of the affected component (e.g., 'ApiModel', 'ExposedEntity', 'Action').\n */\n kind: string\n /**\n * The key of the specific entity or action where the issue occurred.\n * If the error is at the root API model, this might be the ApiModel's key.\n */\n key: string\n /**\n * The specific property being validated, if applicable.\n */\n property?: string\n /**\n * The key of the parent ExposedEntity, if this issue occurred on a nested entity or an action.\n */\n parentExposedEntityKey?: string\n}\n\n/**\n * Represents a single validation issue found within an ApiModel.\n */\nexport interface ApiModelValidationItem {\n /**\n * A unique code identifying the type of validation error. This enables\n * programmatic handling or auto-fixing in the UI (e.g., 'API_MISSING_NAME', 'LIST_ACTION_MISSING_PAGINATION').\n */\n code: string\n /**\n * A human-readable description of the problem.\n */\n message: string\n /**\n * A human-readable suggestion on how to fix the issue.\n */\n suggestion: string\n /**\n * The severity of the validation issue.\n */\n severity: 'error' | 'warning' | 'info'\n /**\n * Contextual information to trace the issue back to its source component.\n */\n context: ApiModelValidationContext\n}\n\n/**\n * The consolidated result of validating an entire ApiModel or a subset of it.\n */\nexport interface ApiModelValidationResult {\n /**\n * A boolean indicating whether the model is structurally sound and ready for publication.\n * Typically true if there are no 'error' severity issues.\n */\n isValid: boolean\n /**\n * The aggregated list of all validation issues found.\n */\n issues: ApiModelValidationItem[]\n}\n\n/**\n * Schema definition for an association.\n *\n * This is used to define how an association is represented in the schema.\n */\nexport interface AssociationSchema {\n /**\n * Whether the target entity should be embedded under the property name.\n * When false, this association is just an information that one entity depend on another.\n * When true, it changes the definition of the schema having this association to\n * add the target schema properties inline with this property.\n *\n * **When true**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": {\n * \"city\": \"example value\",\n * ...\n * }\n * }\n * ```\n *\n * **When false**\n *\n * ```javascript\n * // generated schema for `address` association\n * {\n * \"name\": \"example value\",\n * \"address\": \"the key of the referenced schema\"\n * }\n * ```\n */\n embedded?: boolean\n /**\n * When the association has multiple targets the union type should be\n * set to describe which union this is.\n *\n * Possible values are:\n *\n * - allOf - To validate against `allOf`, the given data must be valid against\n * all of the given sub-schemas. When generating, it's a sum of all properties.\n * - anyOf - To validate against `anyOf`, the given data must be valid against\n * any (one or more) of the given sub-schemas. When generation a schema, it takes first union schema.\n * - oneOf - To validate against `oneOf`, the given data must be valid against\n * exactly one of the given sub-schemas. It behaves the same as `anyOf` when generating a schema\n * - not - The `not` keyword declares that an instance validates if it doesn’t\n * validate against the given sub-schema. It has no use when generating a schema.\n *\n * @default anyOf\n */\n unionType?: 'allOf' | 'anyOf' | 'oneOf' | 'not'\n}\n"]}
|
|
@@ -212,7 +212,7 @@ export function validateApiModelSecurity(model) {
|
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
if (roleProp && !model.session.properties.
|
|
215
|
+
if (roleProp && !model.session.properties.find((p) => p.key === roleProp?.key)) {
|
|
216
216
|
issues.push({
|
|
217
217
|
code: createCode('API', 'MISSING_RBAC_SESSION_PROPERTY'),
|
|
218
218
|
message: 'The user role must be included in the session data for permissions to work.',
|