@dudousxd/nestjs-catalog 0.1.0 → 0.2.1

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.
@@ -162,7 +162,7 @@ export declare function composePrincipalId(applicationId: string, actorId?: stri
162
162
  *
163
163
  * Total, and lenient by design: every id ever written parses, including the
164
164
  * millions written before actors existed. This is what lets a governance query
165
- * keep asking "everything `flip-nestjs` did" — it matches on `applicationId`
165
+ * keep asking "everything this application did" — it matches on `applicationId`
166
166
  * and gets both the machine's own loads and anything a person did through it.
167
167
  *
168
168
  * Splits on the *first* separator, so an actor id that somehow contains one
@@ -101,7 +101,7 @@ function composePrincipalId(applicationId, actorId) {
101
101
  *
102
102
  * Total, and lenient by design: every id ever written parses, including the
103
103
  * millions written before actors existed. This is what lets a governance query
104
- * keep asking "everything `flip-nestjs` did" — it matches on `applicationId`
104
+ * keep asking "everything this application did" — it matches on `applicationId`
105
105
  * and gets both the machine's own loads and anything a person did through it.
106
106
  *
107
107
  * Splits on the *first* separator, so an actor id that somehow contains one
@@ -0,0 +1,31 @@
1
+ import type { CatalogScope } from './catalog.principal';
2
+ /**
3
+ * What a route requires, as metadata a host's guard reads.
4
+ *
5
+ * The vocabulary lives here rather than in whichever package ships the routes,
6
+ * because otherwise every such package would invent its own metadata key and a
7
+ * host would need one guard per package to read them. A host writes ONE guard
8
+ * against these two keys and it governs every catalog route it mounts, from this
9
+ * library or any other.
10
+ *
11
+ * Declaring is deliberately separate from enforcing. This library has no opinion
12
+ * about how a caller is authenticated — that is `CATALOG_PRINCIPAL_RESOLVER` and
13
+ * the host's guard — only about what each route is asking for.
14
+ */
15
+ /** Scopes a route needs. Absence means "authenticated is enough". */
16
+ export declare const REQUIRED_SCOPES = "aviary:catalog:required-scopes";
17
+ /** Whether a route refuses machine principals. */
18
+ export declare const REQUIRES_HUMAN = "aviary:catalog:requires-human";
19
+ /** Declares what a route needs. Absence means "authenticated is enough". */
20
+ export declare const RequireScopes: (...scopes: CatalogScope[]) => import("@nestjs/common").CustomDecorator<string>;
21
+ /**
22
+ * Declares that a route may only be taken by a person, not by an application
23
+ * holding a key.
24
+ *
25
+ * Orthogonal to scopes, and needed because a scope cannot express it. Some
26
+ * decisions want a name against them for reasons that have nothing to do with
27
+ * permission: a machine principal holding `catalog:admin` is perfectly
28
+ * authorised to make them and would leave an application id as the answer to
29
+ * "who did this", which is not an answer.
30
+ */
31
+ export declare const RequireHuman: () => import("@nestjs/common").CustomDecorator<string>;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequireHuman = exports.RequireScopes = exports.REQUIRES_HUMAN = exports.REQUIRED_SCOPES = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * What a route requires, as metadata a host's guard reads.
7
+ *
8
+ * The vocabulary lives here rather than in whichever package ships the routes,
9
+ * because otherwise every such package would invent its own metadata key and a
10
+ * host would need one guard per package to read them. A host writes ONE guard
11
+ * against these two keys and it governs every catalog route it mounts, from this
12
+ * library or any other.
13
+ *
14
+ * Declaring is deliberately separate from enforcing. This library has no opinion
15
+ * about how a caller is authenticated — that is `CATALOG_PRINCIPAL_RESOLVER` and
16
+ * the host's guard — only about what each route is asking for.
17
+ */
18
+ /** Scopes a route needs. Absence means "authenticated is enough". */
19
+ exports.REQUIRED_SCOPES = 'aviary:catalog:required-scopes';
20
+ /** Whether a route refuses machine principals. */
21
+ exports.REQUIRES_HUMAN = 'aviary:catalog:requires-human';
22
+ /** Declares what a route needs. Absence means "authenticated is enough". */
23
+ const RequireScopes = (...scopes) => (0, common_1.SetMetadata)(exports.REQUIRED_SCOPES, scopes);
24
+ exports.RequireScopes = RequireScopes;
25
+ /**
26
+ * Declares that a route may only be taken by a person, not by an application
27
+ * holding a key.
28
+ *
29
+ * Orthogonal to scopes, and needed because a scope cannot express it. Some
30
+ * decisions want a name against them for reasons that have nothing to do with
31
+ * permission: a machine principal holding `catalog:admin` is perfectly
32
+ * authorised to make them and would leave an application id as the answer to
33
+ * "who did this", which is not an answer.
34
+ */
35
+ const RequireHuman = () => (0, common_1.SetMetadata)(exports.REQUIRES_HUMAN, true);
36
+ exports.RequireHuman = RequireHuman;
package/dist/index.d.ts CHANGED
@@ -17,3 +17,4 @@ export { CATALOG_PRINCIPAL_RESOLVER, type CatalogActor, type CatalogGrants, type
17
17
  export { assertNoColumnCollisions, CATALOG_RESERVED_COLUMNS, CATALOG_SNAPSHOT_MODES, CATALOG_STORE, type CarryForwardResult, type CatalogColumnCollision, CatalogColumnCollisionError, type CatalogMergeStore, type CatalogReadQuery, type CatalogReadResult, type CatalogReadStore, type CatalogReservedColumn, type CatalogSnapshotMode, type CatalogStoreCapabilities, type CatalogWriteStore, type ColumnCollisionOptions, findColumnCollisions, isCatalogStoreCapabilities, isReservedColumn, isWriteStore, type SnapshotRef, supportsCarryForward, } from './catalog.store';
18
18
  export { MikroOrmReadStore } from './stores/mikro-orm-read.store';
19
19
  export type { CatalogGraph, CatalogObjectPage, CatalogObjectQuery, CatalogObjectTypeDef, CatalogOverlay, CatalogPropertyDef, CatalogRelationDef, CatalogSnapshot, RelationKind, ScalarType, } from './catalog.types';
20
+ export { REQUIRED_SCOPES, REQUIRES_HUMAN, RequireHuman, RequireScopes, } from './catalog.route-auth';
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.CATALOG_PRINCIPAL_RESOLVER = exports.traceOutcomeFilter = exports.isWorkspaceStore = exports.isTraceStore = exports.isCatalogTraceOutcome = exports.CATALOG_WORKSPACE_STORE = exports.CATALOG_TRACE_STORE = exports.CATALOG_TRACE_OUTCOMES = exports.CatalogService = exports.SubprocessTransformRunner = exports.toCsv = exports.QueryCache = exports.workflowRunOrder = exports.workflowGraphHash = exports.WORKFLOW_NODE_KINDS = exports.WORKFLOW_NODE_ID_PATTERN = exports.WORKFLOW_ISSUE_CODES = exports.WORKFLOW_EXECUTION_MODES = exports.validateWorkflow = exports.TRANSFORM_LANGUAGES = exports.TRANSFORM_RUNNER = exports.supportsWorkflowStages = exports.supportsWorkflows = exports.isWorkflowNodeKind = exports.isWorkflowNode = exports.isWorkflowExecutionMode = exports.isWorkflowEdge = exports.isTransformLanguage = exports.isPipelineStore = exports.isConnectorKind = exports.CONNECTOR_KINDS = exports.CATALOG_PIPELINE_STORE = exports.CatalogRegistry = exports.MikroOrmCatalogRegistry = exports.CATALOG_OVERLAY_STORE = exports.InMemoryCatalogOverlayStore = exports.FileCatalogOverlayStore = exports.CATALOG_OPTIONS = exports.isQueryStore = exports.assertReadOnlyShape = exports.CatalogModule = exports.emitCatalog = exports.channelNameFor = exports.catalogEventPhase = exports.CATALOG_LIB = exports.CATALOG_EVENTS = exports.CATALOG_EVENT_PHASE_FALLBACK = exports.CATALOG_EVENT_PHASE = exports.CatalogType = exports.CatalogProperty = void 0;
18
- exports.MikroOrmReadStore = exports.supportsCarryForward = exports.isWriteStore = exports.isReservedColumn = exports.isCatalogStoreCapabilities = exports.findColumnCollisions = exports.CatalogColumnCollisionError = exports.CATALOG_STORE = exports.CATALOG_SNAPSHOT_MODES = exports.CATALOG_RESERVED_COLUMNS = exports.assertNoColumnCollisions = exports.StaticKeyPrincipalResolver = exports.mayWrite = exports.mayRead = exports.maySeeClassification = exports.PRINCIPAL_ACTOR_SEPARATOR = exports.parsePrincipalId = exports.hasScope = exports.expandScopes = exports.delegatePrincipal = exports.composePrincipalId = void 0;
18
+ exports.RequireScopes = exports.RequireHuman = exports.REQUIRES_HUMAN = exports.REQUIRED_SCOPES = exports.MikroOrmReadStore = exports.supportsCarryForward = exports.isWriteStore = exports.isReservedColumn = exports.isCatalogStoreCapabilities = exports.findColumnCollisions = exports.CatalogColumnCollisionError = exports.CATALOG_STORE = exports.CATALOG_SNAPSHOT_MODES = exports.CATALOG_RESERVED_COLUMNS = exports.assertNoColumnCollisions = exports.StaticKeyPrincipalResolver = exports.mayWrite = exports.mayRead = exports.maySeeClassification = exports.PRINCIPAL_ACTOR_SEPARATOR = exports.parsePrincipalId = exports.hasScope = exports.expandScopes = exports.delegatePrincipal = exports.composePrincipalId = void 0;
19
19
  var catalog_decorators_1 = require("./catalog.decorators");
20
20
  Object.defineProperty(exports, "CatalogProperty", { enumerable: true, get: function () { return catalog_decorators_1.CatalogProperty; } });
21
21
  Object.defineProperty(exports, "CatalogType", { enumerable: true, get: function () { return catalog_decorators_1.CatalogType; } });
@@ -107,3 +107,8 @@ Object.defineProperty(exports, "isWriteStore", { enumerable: true, get: function
107
107
  Object.defineProperty(exports, "supportsCarryForward", { enumerable: true, get: function () { return catalog_store_1.supportsCarryForward; } });
108
108
  var mikro_orm_read_store_1 = require("./stores/mikro-orm-read.store");
109
109
  Object.defineProperty(exports, "MikroOrmReadStore", { enumerable: true, get: function () { return mikro_orm_read_store_1.MikroOrmReadStore; } });
110
+ var catalog_route_auth_1 = require("./catalog.route-auth");
111
+ Object.defineProperty(exports, "REQUIRED_SCOPES", { enumerable: true, get: function () { return catalog_route_auth_1.REQUIRED_SCOPES; } });
112
+ Object.defineProperty(exports, "REQUIRES_HUMAN", { enumerable: true, get: function () { return catalog_route_auth_1.REQUIRES_HUMAN; } });
113
+ Object.defineProperty(exports, "RequireHuman", { enumerable: true, get: function () { return catalog_route_auth_1.RequireHuman; } });
114
+ Object.defineProperty(exports, "RequireScopes", { enumerable: true, get: function () { return catalog_route_auth_1.RequireScopes; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-catalog",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "A metadata registry for NestJS: object types, properties and relations, derived from your ORM and enriched with decorators.",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",