@zenstackhq/server 3.0.0-beta.16 → 3.0.0-beta.17

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/dist/api.js CHANGED
@@ -6,7 +6,7 @@ import { clone, enumerate, lowerCaseFirst, paramCase } from "@zenstackhq/common-
6
6
  import { InputValidationError, NotFoundError, QueryError, RejectedByPolicyError, ZenStackError } from "@zenstackhq/orm";
7
7
  import { Decimal as Decimal2 } from "decimal.js";
8
8
  import SuperJSON2 from "superjson";
9
- import { Linker, Paginator, Relator, Serializer } from "ts-japi";
9
+ import tsjapi from "ts-japi";
10
10
  import UrlPattern from "url-pattern";
11
11
  import z from "zod";
12
12
 
@@ -500,7 +500,7 @@ ${err.stack}` : "Unknown error");
500
500
  status: 200,
501
501
  body: await this.serializeItems(relationInfo.type, entity[relationship], {
502
502
  linkers: {
503
- document: new Linker(() => this.makeLinkUrl(`/${mappedType}/${resourceId}/${relationship}`)),
503
+ document: new tsjapi.Linker(() => this.makeLinkUrl(`/${mappedType}/${resourceId}/${relationship}`)),
504
504
  paginator
505
505
  },
506
506
  include
@@ -547,7 +547,7 @@ ${err.stack}` : "Unknown error");
547
547
  if (entity?.[relationship]) {
548
548
  const serialized = await this.serializeItems(relationInfo.type, entity[relationship], {
549
549
  linkers: {
550
- document: new Linker(() => this.makeLinkUrl(`/${mappedType}/${resourceId}/relationships/${relationship}`)),
550
+ document: new tsjapi.Linker(() => this.makeLinkUrl(`/${mappedType}/${resourceId}/relationships/${relationship}`)),
551
551
  paginator
552
552
  },
553
553
  onlyIdentifier: true
@@ -695,7 +695,7 @@ ${err.stack}` : "Unknown error");
695
695
  return void 0;
696
696
  }
697
697
  const totalPages = Math.ceil(total / limit);
698
- return new Paginator(() => ({
698
+ return new tsjapi.Paginator(() => ({
699
699
  first: this.replaceURLSearchParams(baseUrl, {
700
700
  "page[limit]": limit
701
701
  }),
@@ -917,7 +917,7 @@ ${err.stack}` : "Unknown error");
917
917
  const mappedType = this.mapModelName(type);
918
918
  const serialized = await this.serializeItems(relationInfo.type, entity[relationship], {
919
919
  linkers: {
920
- document: new Linker(() => this.makeLinkUrl(`/${mappedType}/${resourceId}/relationships/${relationship}`))
920
+ document: new tsjapi.Linker(() => this.makeLinkUrl(`/${mappedType}/${resourceId}/relationships/${relationship}`))
921
921
  },
922
922
  onlyIdentifier: true
923
923
  });
@@ -1081,7 +1081,7 @@ ${err.stack}` : "Unknown error");
1081
1081
  if (ids.length < 1) {
1082
1082
  continue;
1083
1083
  }
1084
- const linker = new Linker((items) => Array.isArray(items) ? this.makeLinkUrl(`/${mappedModel}`) : this.makeLinkUrl(`/${mappedModel}/${this.getId(model, items)}`));
1084
+ const linker = new tsjapi.Linker((items) => Array.isArray(items) ? this.makeLinkUrl(`/${mappedModel}`) : this.makeLinkUrl(`/${mappedModel}/${this.getId(model, items)}`));
1085
1085
  linkers[modelLower] = linker;
1086
1086
  let projection = {};
1087
1087
  const modelDef = this.requireModel(model);
@@ -1093,7 +1093,7 @@ ${err.stack}` : "Unknown error");
1093
1093
  if (Object.keys(projection).length === 0) {
1094
1094
  projection = null;
1095
1095
  }
1096
- const serializer = new Serializer(model, {
1096
+ const serializer = new tsjapi.Serializer(model, {
1097
1097
  version: "1.1",
1098
1098
  idKey: this.makeIdKey(ids),
1099
1099
  linkers: {
@@ -1123,13 +1123,13 @@ ${err.stack}` : "Unknown error");
1123
1123
  const fieldIds = this.getIdFields(fieldDef.type);
1124
1124
  if (fieldIds.length > 0) {
1125
1125
  const mappedModel = this.mapModelName(modelLower);
1126
- const relator = new Relator(async (data) => {
1126
+ const relator = new tsjapi.Relator(async (data) => {
1127
1127
  return data[field];
1128
1128
  }, fieldSerializer, {
1129
1129
  relatedName: field,
1130
1130
  linkers: {
1131
- related: new Linker((primary) => this.makeLinkUrl(`/${mappedModel}/${this.getId(model, primary)}/${field}`)),
1132
- relationship: new Linker((primary) => this.makeLinkUrl(`/${mappedModel}/${this.getId(model, primary)}/relationships/${field}`))
1131
+ related: new tsjapi.Linker((primary) => this.makeLinkUrl(`/${mappedModel}/${this.getId(model, primary)}/${field}`)),
1132
+ relationship: new tsjapi.Linker((primary) => this.makeLinkUrl(`/${mappedModel}/${this.getId(model, primary)}/relationships/${field}`))
1133
1133
  }
1134
1134
  });
1135
1135
  relators[field] = relator;