@decaf-ts/db-decorators 0.7.3 → 0.7.5
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/README.md +1 -1
- package/dist/db-decorators.cjs +1 -1
- package/dist/db-decorators.cjs.map +1 -1
- package/dist/db-decorators.js +1 -1
- package/dist/db-decorators.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/interfaces/BulkCrudOperator.d.ts +5 -4
- package/lib/esm/interfaces/Contextual.d.ts +3 -3
- package/lib/esm/interfaces/CrudOperator.d.ts +5 -4
- package/lib/esm/interfaces/IRepository.d.ts +2 -4
- package/lib/esm/model/decorators.d.ts +4 -5
- package/lib/esm/model/decorators.js.map +1 -1
- package/lib/esm/operations/Operations.d.ts +3 -7
- package/lib/esm/operations/Operations.js +1 -3
- package/lib/esm/operations/Operations.js.map +1 -1
- package/lib/esm/operations/OperationsRegistry.d.ts +2 -6
- package/lib/esm/operations/OperationsRegistry.js +0 -2
- package/lib/esm/operations/OperationsRegistry.js.map +1 -1
- package/lib/esm/operations/decorators.d.ts +42 -28
- package/lib/esm/operations/decorators.js +34 -11
- package/lib/esm/operations/decorators.js.map +1 -1
- package/lib/esm/operations/types.d.ts +9 -10
- package/lib/esm/overrides/Model.d.ts +16 -4
- package/lib/esm/overrides/overrides.js +21 -0
- package/lib/esm/overrides/overrides.js.map +1 -1
- package/lib/esm/repository/BaseRepository.d.ts +16 -27
- package/lib/esm/repository/BaseRepository.js +2 -28
- package/lib/esm/repository/BaseRepository.js.map +1 -1
- package/lib/esm/repository/Context.d.ts +9 -8
- package/lib/esm/repository/Context.js +9 -1
- package/lib/esm/repository/Context.js.map +1 -1
- package/lib/esm/repository/Repository.d.ts +9 -6
- package/lib/esm/repository/Repository.js +52 -38
- package/lib/esm/repository/Repository.js.map +1 -1
- package/lib/esm/repository/constants.d.ts +1 -1
- package/lib/esm/repository/constants.js +2 -0
- package/lib/esm/repository/constants.js.map +1 -1
- package/lib/esm/repository/types.d.ts +16 -2
- package/lib/esm/repository/utils.d.ts +6 -32
- package/lib/esm/repository/utils.js +9 -106
- package/lib/esm/repository/utils.js.map +1 -1
- package/lib/esm/validation/decorators.d.ts +4 -5
- package/lib/esm/validation/decorators.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interfaces/BulkCrudOperator.d.ts +5 -4
- package/lib/interfaces/Contextual.d.ts +3 -3
- package/lib/interfaces/CrudOperator.d.ts +5 -4
- package/lib/interfaces/IRepository.d.ts +2 -4
- package/lib/model/decorators.d.ts +4 -5
- package/lib/model/decorators.js.map +1 -1
- package/lib/operations/Operations.cjs +1 -3
- package/lib/operations/Operations.d.ts +3 -7
- package/lib/operations/Operations.js.map +1 -1
- package/lib/operations/OperationsRegistry.cjs +0 -2
- package/lib/operations/OperationsRegistry.d.ts +2 -6
- package/lib/operations/OperationsRegistry.js.map +1 -1
- package/lib/operations/decorators.cjs +36 -12
- package/lib/operations/decorators.d.ts +42 -28
- package/lib/operations/decorators.js.map +1 -1
- package/lib/operations/types.d.ts +9 -10
- package/lib/overrides/Model.d.ts +16 -4
- package/lib/overrides/overrides.cjs +21 -0
- package/lib/overrides/overrides.js.map +1 -1
- package/lib/repository/BaseRepository.cjs +2 -28
- package/lib/repository/BaseRepository.d.ts +16 -27
- package/lib/repository/BaseRepository.js.map +1 -1
- package/lib/repository/Context.cjs +9 -1
- package/lib/repository/Context.d.ts +9 -8
- package/lib/repository/Context.js.map +1 -1
- package/lib/repository/Repository.cjs +51 -37
- package/lib/repository/Repository.d.ts +9 -6
- package/lib/repository/Repository.js.map +1 -1
- package/lib/repository/constants.cjs +2 -0
- package/lib/repository/constants.d.ts +1 -1
- package/lib/repository/constants.js.map +1 -1
- package/lib/repository/types.d.ts +16 -2
- package/lib/repository/utils.cjs +10 -108
- package/lib/repository/utils.d.ts +6 -32
- package/lib/repository/utils.js.map +1 -1
- package/lib/validation/decorators.d.ts +4 -5
- package/lib/validation/decorators.js.map +1 -1
- package/package.json +11 -10
package/lib/repository/utils.cjs
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.reduceErrorsToPrint = reduceErrorsToPrint;
|
|
4
4
|
exports.enforceDBDecorators = enforceDBDecorators;
|
|
5
5
|
exports.getDbDecorators = getDbDecorators;
|
|
6
6
|
const constants_1 = require("./../operations/constants.cjs");
|
|
7
7
|
const errors_1 = require("./errors.cjs");
|
|
8
8
|
const decorators_1 = require("./../operations/decorators.cjs");
|
|
9
9
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* @function getHandlerArgs
|
|
18
|
-
* @memberOf module:db-decorators.Repository
|
|
19
|
-
*/
|
|
20
|
-
const getHandlerArgs = function (dec, prop, m, accum) {
|
|
21
|
-
const name = m.constructor.name;
|
|
22
|
-
if (!name)
|
|
23
|
-
throw new errors_1.InternalError("Could not determine model class");
|
|
24
|
-
accum = accum || {};
|
|
25
|
-
if (dec.props.handlers[name] && dec.props.handlers[name][prop])
|
|
26
|
-
accum = { ...dec.props.handlers[name][prop], ...accum };
|
|
27
|
-
let proto = Object.getPrototypeOf(m);
|
|
28
|
-
if (proto === Object.prototype)
|
|
10
|
+
function reduceErrorsToPrint(errors) {
|
|
11
|
+
return errors.reduce((accum, e, i) => {
|
|
12
|
+
if (e)
|
|
13
|
+
accum =
|
|
14
|
+
typeof accum === "string"
|
|
15
|
+
? accum + `\n - ${i}: ${e.toString()}`
|
|
16
|
+
: ` - ${i}: ${e.toString()}`;
|
|
29
17
|
return accum;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return (0, exports.getHandlerArgs)(dec, prop, proto, accum);
|
|
33
|
-
};
|
|
34
|
-
exports.getHandlerArgs = getHandlerArgs;
|
|
18
|
+
}, undefined);
|
|
19
|
+
}
|
|
35
20
|
/**
|
|
36
21
|
*
|
|
37
22
|
* @param {IRepository<T>} repo
|
|
@@ -106,87 +91,4 @@ function getDbDecorators(model, operation, extraPrefix) {
|
|
|
106
91
|
return accum;
|
|
107
92
|
}, undefined);
|
|
108
93
|
}
|
|
109
|
-
// /**
|
|
110
|
-
// * @summary Retrieves the decorators for an object's properties prefixed by {@param prefixes} recursively
|
|
111
|
-
// * @param model
|
|
112
|
-
// * @param accum
|
|
113
|
-
// * @param prefixes
|
|
114
|
-
// *
|
|
115
|
-
// * @function getAllPropertyDecoratorsRecursive
|
|
116
|
-
// * @memberOf module:db-decorators.Repository
|
|
117
|
-
// */
|
|
118
|
-
// export const getAllPropertyDecoratorsRecursive = function <T extends Model>(
|
|
119
|
-
// model: T,
|
|
120
|
-
// accum: { [indexer: string]: any[] } | undefined,
|
|
121
|
-
// ...prefixes: string[]
|
|
122
|
-
// ): { [indexer: string]: any[] } | undefined {
|
|
123
|
-
// const accumulator = accum || {};
|
|
124
|
-
// const mergeDecorators = function (decs: { [indexer: string]: any[] }) {
|
|
125
|
-
// const pushOrSquash = (key: string, ...values: any[]) => {
|
|
126
|
-
// values.forEach((val) => {
|
|
127
|
-
// let match: any;
|
|
128
|
-
// if (
|
|
129
|
-
// !(match = accumulator[key].find((e) => e.key === val.key)) ||
|
|
130
|
-
// match.props.operation !== val.props.operation
|
|
131
|
-
// ) {
|
|
132
|
-
// accumulator[key].push(val);
|
|
133
|
-
// return;
|
|
134
|
-
// }
|
|
135
|
-
// if (val.key === ModelKeys.TYPE) return;
|
|
136
|
-
// const { handlers, operation } = val.props;
|
|
137
|
-
// if (
|
|
138
|
-
// !operation ||
|
|
139
|
-
// !operation.match(
|
|
140
|
-
// new RegExp(
|
|
141
|
-
// `^(:?${OperationKeys.ON}|${OperationKeys.AFTER})(:?${OperationKeys.CREATE}|${OperationKeys.READ}|${OperationKeys.UPDATE}|${OperationKeys.DELETE})$`
|
|
142
|
-
// )
|
|
143
|
-
// )
|
|
144
|
-
// ) {
|
|
145
|
-
// accumulator[key].push(val);
|
|
146
|
-
// return;
|
|
147
|
-
// }
|
|
148
|
-
// const accumHandlers = match.props.handlers;
|
|
149
|
-
// Object.entries(handlers).forEach(([clazz, handlerDef]) => {
|
|
150
|
-
// if (!(clazz in accumHandlers)) {
|
|
151
|
-
// accumHandlers[clazz] = handlerDef;
|
|
152
|
-
// return;
|
|
153
|
-
// }
|
|
154
|
-
// Object.entries(handlerDef as object).forEach(
|
|
155
|
-
// ([handlerProp, handler]) => {
|
|
156
|
-
// if (!(handlerProp in accumHandlers[clazz])) {
|
|
157
|
-
// accumHandlers[clazz][handlerProp] = handler;
|
|
158
|
-
// return;
|
|
159
|
-
// }
|
|
160
|
-
// Object.entries(handler as object).forEach(
|
|
161
|
-
// ([handlerKey, argsObj]) => {
|
|
162
|
-
// if (!(handlerKey in accumHandlers[clazz][handlerProp])) {
|
|
163
|
-
// accumHandlers[clazz][handlerProp][handlerKey] = argsObj;
|
|
164
|
-
// return;
|
|
165
|
-
// }
|
|
166
|
-
// console.warn(
|
|
167
|
-
// `Skipping handler registration for ${clazz} under prop ${handlerProp} because handler is the same`
|
|
168
|
-
// );
|
|
169
|
-
// }
|
|
170
|
-
// );
|
|
171
|
-
// }
|
|
172
|
-
// );
|
|
173
|
-
// });
|
|
174
|
-
// });
|
|
175
|
-
// };
|
|
176
|
-
// Object.entries(decs).forEach(([key, value]) => {
|
|
177
|
-
// accumulator[key] = accumulator[key] || [];
|
|
178
|
-
// pushOrSquash(key, ...value);
|
|
179
|
-
// });
|
|
180
|
-
// };
|
|
181
|
-
// const decs: { [indexer: string]: any[] } | undefined =
|
|
182
|
-
// Reflection.getAllPropertyDecorators(model, ...prefixes);
|
|
183
|
-
// if (decs) mergeDecorators(decs);
|
|
184
|
-
// if (Object.getPrototypeOf(model) === Object.prototype) return accumulator;
|
|
185
|
-
// // const name = model.constructor.name;
|
|
186
|
-
// const proto = Object.getPrototypeOf(model);
|
|
187
|
-
// if (!proto) return accumulator;
|
|
188
|
-
// // if (proto.constructor && proto.constructor.name === name)
|
|
189
|
-
// // proto = Object.getPrototypeOf(proto)
|
|
190
|
-
// return getAllPropertyDecoratorsRecursive(proto, accumulator, ...prefixes);
|
|
191
|
-
// };
|
|
192
94
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,38 +1,12 @@
|
|
|
1
1
|
import { IRepository } from "../interfaces/IRepository";
|
|
2
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
+
import { Model, ModelErrorDefinition } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { Context } from "./Context";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @description Context arguments for repository operations.
|
|
8
|
-
* @summary Represents the context and arguments for repository operations.
|
|
9
|
-
* This type is used to pass context and arguments between repository methods.
|
|
10
|
-
* @template F - The repository flags type, defaults to RepositoryFlags
|
|
11
|
-
* @template C - The context type, defaults to Context<F>
|
|
12
|
-
* @typedef {Object} ContextArgs
|
|
13
|
-
* @property {C} context - The operation context
|
|
14
|
-
* @property {any[]} args - The operation arguments
|
|
15
|
-
* @memberOf module:db-decorators
|
|
16
|
-
*/
|
|
17
|
-
export type ContextArgs<F extends RepositoryFlags = RepositoryFlags, C extends Context<F> = Context<F>> = {
|
|
4
|
+
import { ContextOfRepository } from "./types";
|
|
5
|
+
export type ContextArgs<C extends Context<any>> = {
|
|
18
6
|
context: C;
|
|
19
|
-
args: any[];
|
|
7
|
+
args: [...any[], C];
|
|
20
8
|
};
|
|
21
|
-
|
|
22
|
-
* @summary retrieves the arguments for the handler
|
|
23
|
-
* @param {any} dec the decorator
|
|
24
|
-
* @param {string} prop the property name
|
|
25
|
-
* @param {{}} m the model
|
|
26
|
-
* @param {{}} [accum] accumulator used for internal recursiveness
|
|
27
|
-
*
|
|
28
|
-
* @function getHandlerArgs
|
|
29
|
-
* @memberOf module:db-decorators.Repository
|
|
30
|
-
*/
|
|
31
|
-
export declare const getHandlerArgs: (dec: any, prop: string, m: Constructor<any>, accum?: Record<string, {
|
|
32
|
-
args: string[];
|
|
33
|
-
}>) => Record<string, {
|
|
34
|
-
args: string[];
|
|
35
|
-
}> | void;
|
|
9
|
+
export declare function reduceErrorsToPrint(errors: (ModelErrorDefinition | undefined)[]): string | undefined;
|
|
36
10
|
/**
|
|
37
11
|
*
|
|
38
12
|
* @param {IRepository<T>} repo
|
|
@@ -46,7 +20,7 @@ export declare const getHandlerArgs: (dec: any, prop: string, m: Constructor<any
|
|
|
46
20
|
*
|
|
47
21
|
* @memberOf db-decorators.utils
|
|
48
22
|
*/
|
|
49
|
-
export declare function enforceDBDecorators<M extends Model<true | false>, R extends IRepository<M,
|
|
23
|
+
export declare function enforceDBDecorators<M extends Model<true | false>, R extends IRepository<M, any>, V extends object = object>(repo: R, context: ContextOfRepository<R>, model: M, operation: string, prefix: string, oldModel?: M): Promise<void>;
|
|
50
24
|
/**
|
|
51
25
|
* Specific for DB Decorators
|
|
52
26
|
* @param {T} model
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/repository/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/repository/utils.ts"],"names":[],"mappings":";;AAmBA,kDAWC;AAeD,kDA6CC;AAYD,0CA8BC;AAnID,6DAAyE;AACzE,yCAAyC;AAGzC,+DAIkC;AAElC,qDAA6D;AAQ7D,SAAgB,mBAAmB,CACjC,MAA4C;IAE5C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAyB,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE;QACvD,IAAI,CAAC;YACH,KAAK;gBACH,OAAO,KAAK,KAAK,QAAQ;oBACvB,CAAC,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE;oB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AAG;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAE1D,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK;gBAAE,KAAK,GAAG,EAAE,CAAC;YACvB,KAAK,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QAC1B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,EACD,SAAS,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -2,8 +2,7 @@ import "./validation";
|
|
|
2
2
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { OperationKeys } from "../operations/constants";
|
|
4
4
|
import { IRepository } from "../interfaces/IRepository";
|
|
5
|
-
import {
|
|
6
|
-
import { RepositoryFlags } from "../repository/types";
|
|
5
|
+
import { ContextOfRepository } from "../repository/index";
|
|
7
6
|
/**
|
|
8
7
|
* @description Prevents a property from being modified after initial creation.
|
|
9
8
|
* @summary Marks the property as readonly, causing validation errors if attempts are made to modify it during updates.
|
|
@@ -28,7 +27,7 @@ export declare function readonly(message?: string): (target: any, propertyKey?:
|
|
|
28
27
|
* @return {Promise<void>} A promise that resolves when the timestamp has been set
|
|
29
28
|
* @function timestampHandler
|
|
30
29
|
*/
|
|
31
|
-
export declare function timestampHandler<M extends Model, R extends IRepository<M,
|
|
30
|
+
export declare function timestampHandler<M extends Model, R extends IRepository<M, any>, V>(this: R, context: ContextOfRepository<R>, data: V, key: keyof M, model: M): Promise<void>;
|
|
32
31
|
/**
|
|
33
32
|
* @description Automatically manages timestamp properties for tracking creation and update times.
|
|
34
33
|
* @summary Marks the property as a timestamp, making it required and ensuring it's a valid date. The property will be automatically updated with the current timestamp during specified operations.
|
|
@@ -92,7 +91,7 @@ export declare function timestamp(operation?: OperationKeys[], format?: string):
|
|
|
92
91
|
* @return {Promise<void>} A promise that resolves when the property has been serialized
|
|
93
92
|
* @function serializeOnCreateUpdate
|
|
94
93
|
*/
|
|
95
|
-
export declare function serializeOnCreateUpdate<M extends Model, R extends IRepository<M,
|
|
94
|
+
export declare function serializeOnCreateUpdate<M extends Model, R extends IRepository<M, any>, V>(this: R, context: ContextOfRepository<R>, data: V, key: keyof M, model: M): Promise<void>;
|
|
96
95
|
/**
|
|
97
96
|
* @description Handler function that deserializes a property from JSON string after database operations.
|
|
98
97
|
* @summary Converts a JSON string property back to its original complex object form after retrieving it from the database.
|
|
@@ -108,7 +107,7 @@ export declare function serializeOnCreateUpdate<M extends Model, R extends IRepo
|
|
|
108
107
|
* @return {Promise<void>} A promise that resolves when the property has been deserialized
|
|
109
108
|
* @function serializeAfterAll
|
|
110
109
|
*/
|
|
111
|
-
export declare function serializeAfterAll<M extends Model, R extends IRepository<M,
|
|
110
|
+
export declare function serializeAfterAll<M extends Model, R extends IRepository<M, any>, V>(this: R, context: ContextOfRepository<R>, data: V, key: keyof M, model: M): Promise<void>;
|
|
112
111
|
/**
|
|
113
112
|
* @description Enables automatic JSON serialization and deserialization for complex object properties.
|
|
114
113
|
* @summary Decorator that automatically converts complex objects to JSON strings before storing in the database and back to objects when retrieving them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/validation/decorators.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/validation/decorators.ts"],"names":[],"mappings":";;AA+BA,4BAeC;AAiBD,4CAYC;AAiDD,8BA+BC;AAiBD,0DAoBC;AAiBD,8CAqBC;AA6BD,8BAOC;AA1QD,4BAAsB;AACtB,yEAOwC;AACxC,wDAAsE;AACtE,+CAAqD;AACrD,6DAAsE;AACtE,+DAAqE;AAErE,uDAA0D;AAC1D,qDAK8B;AAG9B;;;;;;;GAOG;AACH,SAAgB,QAAQ,CACtB,UAAkB,kCAAsB,CAAC,QAAQ,CAAC,OAAO;IAEzD,MAAM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,CAAC,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,MAAM,IAAI,2BAAkB,CAC1B,yBAAyB,GAAG,CAAC,QAAQ,EAAE,sBAAsB,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,EAAE,CAC5F,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,SAAS;IACvB,OAAO,IAAA,kBAAK,EACV,IAAA,2BAAc,EAAC,uBAAuB,CAAC,EACvC,IAAA,kBAAK,EAAC,wBAAY,CAAC,GAAG,EAAE,iBAAiB,CAAC,EAC1C,IAAA,2BAAI,EAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACtB,IAAA,qBAAQ,EAAC,kBAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAC/B,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/db-decorators",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Agnostic database decorators and repository",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -34,13 +34,14 @@
|
|
|
34
34
|
"uml": "cd workdocs/uml && for FILE in ./*.puml; do docker run --rm -v $(pwd):/work -w /work miy4/plantuml -DPLANTUML_LIMIT_SIZE=8192 -tpng $FILE; done && cd ../.. && cp -fr workdocs/uml/*.png workdocs/resources/",
|
|
35
35
|
"docs": "npx rimraf ./docs && mkdir docs && npx build-scripts --docs",
|
|
36
36
|
"publish-docs": "docker run -it --rm --user $(id -u):$(id -g) -v \"$(pwd)/workdocs/confluence:/content\" -e ATLASSIAN_API_TOKEN=$(cat .confluence-token) ghcr.io/markdown-confluence/publish:latest",
|
|
37
|
-
"repo:init": "codex
|
|
38
|
-
"repo:setup": "codex
|
|
39
|
-
"repo:doc": "codex
|
|
40
|
-
"repo:tests": "codex
|
|
41
|
-
"repo:
|
|
42
|
-
"repo:
|
|
43
|
-
"
|
|
37
|
+
"repo:init": "npm run codex -- \"$(cat ./workdocs/ai/repo-setup.md)\nbase_path is `./`, initialize the repository\"",
|
|
38
|
+
"repo:setup": "npm run codex -- \"$(cat ./workdocs/ai/repo-setup.md)\nbase_path is ./\"",
|
|
39
|
+
"repo:doc": "npm run codex -- \"$(cat ./workdocs/ai/doc.md) $(cat ./workdocs/ai/bulk-docs.md)\nbase_path is ./\"",
|
|
40
|
+
"repo:tests": "npm run codex -- \"$(cat ./workdocs/ai/bulk-tests.md)\nbase_path is ./ and coverage is 95%\"",
|
|
41
|
+
"repo:notes": "npm run codex -- \"$(cat ./workdocs/ai/release-notes.md)\nbase_path is ./\"",
|
|
42
|
+
"repo:readme": "npm run codex -- \"$(cat ./workdocs/ai/update-readme.md)\nbase_path is ./\"",
|
|
43
|
+
"repo:pr": "npm run repo:doc && npm run repo:tests && npm run repo:notes && npm run repo:readme",
|
|
44
|
+
"codex": "codex -s workspace-write exec"
|
|
44
45
|
},
|
|
45
46
|
"repository": {
|
|
46
47
|
"type": "git",
|
|
@@ -74,12 +75,12 @@
|
|
|
74
75
|
},
|
|
75
76
|
"homepage": "https://github.com/decaf-ts/db-decorators#readme",
|
|
76
77
|
"devDependencies": {
|
|
77
|
-
"@decaf-ts/logging": "latest",
|
|
78
78
|
"@decaf-ts/utils": "latest"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@decaf-ts/decoration": "latest",
|
|
82
82
|
"@decaf-ts/decorator-validation": "latest",
|
|
83
|
-
"@decaf-ts/injectable-decorators": "latest"
|
|
83
|
+
"@decaf-ts/injectable-decorators": "latest",
|
|
84
|
+
"@decaf-ts/logging": "latest"
|
|
84
85
|
}
|
|
85
86
|
}
|