@ai0x0/utils 0.0.40 → 0.0.41

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.
@@ -81,6 +81,8 @@ export const getOperation = createGetOperation({ db, getSession });
81
81
  export const getListOperation = createGetListOperation({ db, getSession });
82
82
  ```
83
83
 
84
+ `db` may be omitted for operation-only endpoints that should not touch the database even when `table` is supplied for OpenAPI tags.
85
+
84
86
  `getSession(req)` **must** return `{ userId?: string } | undefined` (a Promise is fine). Throwing rejects the request; returning `undefined` disables ownership checks for that call.
85
87
 
86
88
  ## Factory Catalog
@@ -96,7 +98,7 @@ export const getListOperation = createGetListOperation({ db, getSession });
96
98
 
97
99
  `tags` can be passed manually to override the default OpenAPI tag inferred from `table`.
98
100
 
99
- `table` is optional for route operations. When omitted, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
101
+ `table` and factory-level `db` are optional for route operations. When `table` is omitted or `db` is not provided, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
100
102
 
101
103
  ## Canonical Examples
102
104
 
package/SKILL.md CHANGED
@@ -60,6 +60,8 @@ export const getOperation = createGetOperation({ db, getSession });
60
60
  export const getListOperation = createGetListOperation({ db, getSession });
61
61
  ```
62
62
 
63
+ `db` may be omitted for operation-only endpoints that should not touch the database even when `table` is supplied for OpenAPI tags.
64
+
63
65
  `getSession(req)` **must** return `{ userId?: string } | undefined` (a Promise is fine). Throwing rejects the request; returning `undefined` disables ownership checks for that call.
64
66
 
65
67
  ## Factory Catalog
@@ -75,7 +77,7 @@ export const getListOperation = createGetListOperation({ db, getSession });
75
77
 
76
78
  `tags` can be passed manually to override the default OpenAPI tag inferred from `table`.
77
79
 
78
- `table` is optional for route operations. When omitted, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
80
+ `table` and factory-level `db` are optional for route operations. When `table` is omitted or `db` is not provided, the operation still parses input, applies `setParams` / `setBody`, session-derived fields, and `onSuccess`, but skips the built-in table action (`select` / `insert` / `update` / `delete`). Use this for custom endpoints that want the same OpenAPI and response wiring without a direct table operation.
79
81
 
80
82
  ## Canonical Examples
81
83
 
@@ -58,7 +58,7 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
58
58
  userId = _ref4.userId;
59
59
  body.creatorId = userId;
60
60
  case 13:
61
- if (!table) {
61
+ if (!(table && db)) {
62
62
  _context.next = 19;
63
63
  break;
64
64
  }
@@ -71,7 +71,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
71
71
  params.creatorId = userId;
72
72
  case 16:
73
73
  mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
74
- if (!table) {
74
+ if (!(table && db)) {
75
75
  _context.next = 23;
76
76
  break;
77
77
  }
@@ -70,7 +70,7 @@ export var createGetOperation = function createGetOperation(_ref) {
70
70
  params.creatorId = userId;
71
71
  case 16:
72
72
  mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
73
- if (!table) {
73
+ if (!(table && db)) {
74
74
  _context.next = 23;
75
75
  break;
76
76
  }
@@ -76,7 +76,7 @@ export var createPostOperation = function createPostOperation(_ref) {
76
76
  params = _objectSpread({
77
77
  creatorId: userId
78
78
  }, mergedBody);
79
- if (!table) {
79
+ if (!(table && db)) {
80
80
  _context.next = 25;
81
81
  break;
82
82
  }
@@ -77,7 +77,7 @@ export var createPutOperation = function createPutOperation(_ref) {
77
77
  params = _objectSpread({
78
78
  editorId: userId
79
79
  }, mergedBody);
80
- if (!table) {
80
+ if (!(table && db)) {
81
81
  _context.next = 25;
82
82
  break;
83
83
  }
@@ -58,7 +58,7 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
58
58
  userId = _ref4.userId;
59
59
  body.creatorId = userId;
60
60
  case 13:
61
- if (!table) {
61
+ if (!(table && db)) {
62
62
  _context.next = 19;
63
63
  break;
64
64
  }
@@ -71,7 +71,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
71
71
  params.creatorId = userId;
72
72
  case 16:
73
73
  mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
74
- if (!table) {
74
+ if (!(table && db)) {
75
75
  _context.next = 23;
76
76
  break;
77
77
  }
@@ -70,7 +70,7 @@ export var createGetOperation = function createGetOperation(_ref) {
70
70
  params.creatorId = userId;
71
71
  case 16:
72
72
  mergedParams = Object.assign(Object.fromEntries(new URL(req.url).searchParams), params);
73
- if (!table) {
73
+ if (!(table && db)) {
74
74
  _context.next = 23;
75
75
  break;
76
76
  }
@@ -76,7 +76,7 @@ export var createPostOperation = function createPostOperation(_ref) {
76
76
  params = _objectSpread({
77
77
  creatorId: userId
78
78
  }, mergedBody);
79
- if (!table) {
79
+ if (!(table && db)) {
80
80
  _context.next = 25;
81
81
  break;
82
82
  }
@@ -77,7 +77,7 @@ export var createPutOperation = function createPutOperation(_ref) {
77
77
  params = _objectSpread({
78
78
  editorId: userId
79
79
  }, mergedBody);
80
- if (!table) {
80
+ if (!(table && db)) {
81
81
  _context.next = 25;
82
82
  break;
83
83
  }
@@ -65,7 +65,7 @@ var createDeleteOperation = ({
65
65
  const { userId } = await getSession(req) || {};
66
66
  body.creatorId = userId;
67
67
  }
68
- const data = table ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
68
+ const data = table && db ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
69
69
  await (onSuccess == null ? void 0 : onSuccess({ data, params: body }));
70
70
  return import_next_rest_framework.TypedNextResponse.json(data, {
71
71
  status: 200
@@ -78,7 +78,7 @@ var createGetListOperation = ({
78
78
  Object.fromEntries(new URL(req.url).searchParams),
79
79
  params
80
80
  );
81
- let result = table ? await (0, import_actions.createGetListAction)({
81
+ let result = table && db ? await (0, import_actions.createGetListAction)({
82
82
  bodySchema,
83
83
  db,
84
84
  jsonArrayFields,
@@ -77,7 +77,7 @@ var createGetOperation = ({
77
77
  Object.fromEntries(new URL(req.url).searchParams),
78
78
  params
79
79
  );
80
- const rawResult = table ? await (0, import_actions.createGetAction)({
80
+ const rawResult = table && db ? await (0, import_actions.createGetAction)({
81
81
  bodySchema,
82
82
  db,
83
83
  jsonArrayFields,
@@ -72,7 +72,9 @@ var createPostOperation = ({
72
72
  )) || {};
73
73
  const mergedBody = { ...body, ...extraBody };
74
74
  const params = { creatorId: userId, ...mergedBody };
75
- const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(params))[0] : params;
75
+ const raw = table && db ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
76
+ params
77
+ ))[0] : params;
76
78
  const data = onSuccess ? await onSuccess({
77
79
  data: raw,
78
80
  params
@@ -74,7 +74,7 @@ var createPutOperation = ({
74
74
  )) || {};
75
75
  const mergedBody = { ...body, ...extraBody };
76
76
  const params = { editorId: userId, ...mergedBody };
77
- const raw = table ? await (0, import_actions.createPutAction)({
77
+ const raw = table && db ? await (0, import_actions.createPutAction)({
78
78
  bodySchema,
79
79
  table,
80
80
  db
@@ -65,7 +65,7 @@ var createDeleteOperation = ({
65
65
  const { userId } = await getSession(req) || {};
66
66
  body.creatorId = userId;
67
67
  }
68
- const data = table ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
68
+ const data = table && db ? await (0, import_actions.createDeleteAction)({ table, db })(body) : body;
69
69
  await (onSuccess == null ? void 0 : onSuccess({ data, params: body }));
70
70
  return import_next_rest_framework.TypedNextResponse.json(data, {
71
71
  status: 200
@@ -78,7 +78,7 @@ var createGetListOperation = ({
78
78
  Object.fromEntries(new URL(req.url).searchParams),
79
79
  params
80
80
  );
81
- let result = table ? await (0, import_actions.createGetListAction)({
81
+ let result = table && db ? await (0, import_actions.createGetListAction)({
82
82
  bodySchema,
83
83
  db,
84
84
  jsonArrayFields,
@@ -77,7 +77,7 @@ var createGetOperation = ({
77
77
  Object.fromEntries(new URL(req.url).searchParams),
78
78
  params
79
79
  );
80
- const rawResult = table ? await (0, import_actions.createGetAction)({
80
+ const rawResult = table && db ? await (0, import_actions.createGetAction)({
81
81
  bodySchema,
82
82
  db,
83
83
  jsonArrayFields,
@@ -72,7 +72,9 @@ var createPostOperation = ({
72
72
  )) || {};
73
73
  const mergedBody = { ...body, ...extraBody };
74
74
  const params = { creatorId: userId, ...mergedBody };
75
- const raw = table ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(params))[0] : params;
75
+ const raw = table && db ? (await (0, import_actions.createPostAction)({ bodySchema, db, table })(
76
+ params
77
+ ))[0] : params;
76
78
  const data = onSuccess ? await onSuccess({
77
79
  data: raw,
78
80
  params
@@ -74,7 +74,7 @@ var createPutOperation = ({
74
74
  )) || {};
75
75
  const mergedBody = { ...body, ...extraBody };
76
76
  const params = { editorId: userId, ...mergedBody };
77
- const raw = table ? await (0, import_actions.createPutAction)({
77
+ const raw = table && db ? await (0, import_actions.createPutAction)({
78
78
  bodySchema,
79
79
  table,
80
80
  db
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai0x0/utils",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "AI0x0 utils",
5
5
  "keywords": [
6
6
  "ai0x0"