azure-mock 2.28.0 → 2.29.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/README.md CHANGED
@@ -47,6 +47,17 @@ const entity = await mockTableClient.getEntity("pk", "rk");
47
47
 
48
48
  Replace real Azure clients with their mock equivalents by swapping them in your test setup or local `.env` configuration.
49
49
 
50
+ ### Commands
51
+
52
+ Run from `packages/azure-mock/`:
53
+
54
+ ```bash
55
+ pnpm build # compile to dist/
56
+ pnpm test # vitest watch mode (coverage is run from the repo root)
57
+ pnpm lint:fix # auto-fix lint
58
+ pnpm typecheck # type check
59
+ ```
60
+
50
61
  ## <a name="license">⚖️ License</a>
51
62
 
52
63
  This project is licensed under the [Apache-2.0 license](https://github.com/Esposter/Esposter/blob/main/LICENSE).
package/dist/index.d.ts CHANGED
@@ -944,6 +944,7 @@ declare class MockBlockBlobClient extends MockBlobClient implements Except<Block
944
944
  * const content = await blockBlobClient.downloadToBuffer();
945
945
  */
946
946
  declare class MockContainerClient implements Except<ContainerClient, "accountName"> {
947
+ #private;
947
948
  connectionString: string;
948
949
  containerName: string;
949
950
  credential: AnonymousCredential;
@@ -978,8 +979,6 @@ declare class MockContainerClient implements Except<ContainerClient, "accountNam
978
979
  blockBlobClient: BlockBlobClient;
979
980
  response: BlockBlobUploadResponse;
980
981
  }>;
981
- private getBlobHierarchyItemIterator;
982
- private getBlobItemIterator;
983
982
  }
984
983
  //#endregion
985
984
  //#region src/models/eventGrid/MockEventGridPublisherClient.d.ts
@@ -1077,6 +1076,7 @@ declare class MockSearchClient<TModel extends object = Record<string, unknown>>
1077
1076
  * const entity = await mockTableClient.getEntity("partitionKey", "rowKey");
1078
1077
  */
1079
1078
  declare class MockTableClient<TEntity extends TableEntity = TableEntity> implements Except<TableClient, "pipeline"> {
1079
+ #private;
1080
1080
  entityType: TEntity;
1081
1081
  tableName: string;
1082
1082
  url: string;
@@ -1093,10 +1093,6 @@ declare class MockTableClient<TEntity extends TableEntity = TableEntity> impleme
1093
1093
  submitTransaction(actions: Parameters<TableClient["submitTransaction"]>[0]): Promise<TableTransactionResponse>;
1094
1094
  updateEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode): Promise<TableMergeEntityHeaders>;
1095
1095
  upsertEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode): Promise<TableMergeEntityHeaders>;
1096
- private getCompositeKey;
1097
- private getEtag;
1098
- private mergeEntity;
1099
- private withMetadata;
1100
1096
  }
1101
1097
  //#endregion
1102
1098
  //#region src/models/webPubSub/MockWebPubSubServiceClient.d.ts
package/dist/index.js CHANGED
@@ -564,7 +564,7 @@ var MockContainerClient = class {
564
564
  throw new Error("Method not implemented.");
565
565
  }
566
566
  listBlobsByHierarchy(delimiter, options) {
567
- const blobHierarchyItemIterator = this.getBlobHierarchyItemIterator(delimiter, options);
567
+ const blobHierarchyItemIterator = this.#getBlobHierarchyItemIterator(delimiter, options);
568
568
  return {
569
569
  byPage: () => async function* () {
570
570
  const allBlobItems = [];
@@ -607,7 +607,7 @@ var MockContainerClient = class {
607
607
  };
608
608
  }
609
609
  listBlobsFlat() {
610
- const blobItemIterator = this.getBlobItemIterator();
610
+ const blobItemIterator = this.#getBlobItemIterator();
611
611
  return {
612
612
  byPage: () => async function* () {
613
613
  const allBlobItems = [];
@@ -657,7 +657,7 @@ var MockContainerClient = class {
657
657
  response: await blockBlobClient.upload(body, contentLength)
658
658
  };
659
659
  }
660
- async *getBlobHierarchyItemIterator(delimiter, options) {
660
+ async *#getBlobHierarchyItemIterator(delimiter, options) {
661
661
  const prefix = options?.prefix ?? "";
662
662
  const uniqueSubprefixes = /* @__PURE__ */ new Set();
663
663
  const blobsInCurrentLevel = [];
@@ -693,7 +693,7 @@ var MockContainerClient = class {
693
693
  ...blobItem
694
694
  });
695
695
  }
696
- async *getBlobItemIterator() {
696
+ async *#getBlobItemIterator() {
697
697
  for (const [name, buffer] of this.container.entries()) yield await Promise.resolve({
698
698
  deleted: false,
699
699
  name,
@@ -1104,19 +1104,19 @@ var MockTableClient = class {
1104
1104
  this.url = `${MOCK_TABLE_BASE_URL}/${this.tableName}`;
1105
1105
  }
1106
1106
  createEntity(entity) {
1107
- const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
1107
+ const key = this.#getCompositeKey(entity.partitionKey, entity.rowKey);
1108
1108
  if (this.table.has(key)) throw new MockRestError("The specified entity already exists.", 409);
1109
1109
  this.table.set(key, entity);
1110
1110
  return Promise.resolve({
1111
1111
  date: /* @__PURE__ */ new Date(),
1112
- etag: this.getEtag()
1112
+ etag: this.#getEtag()
1113
1113
  });
1114
1114
  }
1115
1115
  createTable() {
1116
1116
  throw new Error("Method not implemented.");
1117
1117
  }
1118
1118
  deleteEntity(partitionKey, rowKey) {
1119
- const key = this.getCompositeKey(partitionKey, rowKey);
1119
+ const key = this.#getCompositeKey(partitionKey, rowKey);
1120
1120
  if (!this.table.has(key)) throw new MockRestError("The specified resource does not exist.", 404);
1121
1121
  this.table.delete(key);
1122
1122
  return Promise.resolve({});
@@ -1128,16 +1128,16 @@ var MockTableClient = class {
1128
1128
  throw new Error("Method not implemented.");
1129
1129
  }
1130
1130
  getEntity(partitionKey, rowKey) {
1131
- const key = this.getCompositeKey(partitionKey, rowKey);
1131
+ const key = this.#getCompositeKey(partitionKey, rowKey);
1132
1132
  const entity = this.table.get(key);
1133
1133
  if (!entity) throw new MockRestError("The specified resource does not exist.", 404);
1134
1134
  return Promise.resolve({
1135
1135
  ...entity,
1136
- etag: this.getEtag()
1136
+ etag: this.#getEtag()
1137
1137
  });
1138
1138
  }
1139
1139
  listEntities(options) {
1140
- const withMetadata = this.withMetadata.bind(this);
1140
+ const withMetadata = this.#withMetadata.bind(this);
1141
1141
  const filter = options?.queryOptions?.filter;
1142
1142
  const tableEntities = [...this.table.values()];
1143
1143
  const predicate = filter ? createFilterPredicate(filter) : void 0;
@@ -1198,50 +1198,50 @@ var MockTableClient = class {
1198
1198
  };
1199
1199
  }
1200
1200
  updateEntity(entity, mode = "Merge") {
1201
- const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
1201
+ const key = this.#getCompositeKey(entity.partitionKey, entity.rowKey);
1202
1202
  const existingEntity = this.table.get(key);
1203
1203
  if (!existingEntity) throw new MockRestError("The specified resource does not exist.", 404);
1204
- else if (mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
1204
+ else if (mode === "Merge") return this.#mergeEntity(key, existingEntity, entity);
1205
1205
  else {
1206
1206
  this.table.set(key, entity);
1207
1207
  return Promise.resolve({
1208
1208
  date: /* @__PURE__ */ new Date(),
1209
- etag: this.getEtag()
1209
+ etag: this.#getEtag()
1210
1210
  });
1211
1211
  }
1212
1212
  }
1213
1213
  upsertEntity(entity, mode = "Merge") {
1214
- const key = this.getCompositeKey(entity.partitionKey, entity.rowKey);
1214
+ const key = this.#getCompositeKey(entity.partitionKey, entity.rowKey);
1215
1215
  const existingEntity = this.table.get(key);
1216
- if (existingEntity && mode === "Merge") return this.mergeEntity(key, existingEntity, entity);
1216
+ if (existingEntity && mode === "Merge") return this.#mergeEntity(key, existingEntity, entity);
1217
1217
  else {
1218
1218
  this.table.set(key, entity);
1219
1219
  return Promise.resolve({
1220
1220
  date: /* @__PURE__ */ new Date(),
1221
- etag: this.getEtag()
1221
+ etag: this.#getEtag()
1222
1222
  });
1223
1223
  }
1224
1224
  }
1225
- getCompositeKey(partitionKey, rowKey) {
1225
+ #getCompositeKey(partitionKey, rowKey) {
1226
1226
  return `${partitionKey}${ID_SEPARATOR}${rowKey}`;
1227
1227
  }
1228
- getEtag() {
1228
+ #getEtag() {
1229
1229
  return `W/"datetime'${(/* @__PURE__ */ new Date()).toISOString()}'"`;
1230
1230
  }
1231
- mergeEntity(key, entity, entityToMerge) {
1231
+ #mergeEntity(key, entity, entityToMerge) {
1232
1232
  this.table.set(key, {
1233
1233
  ...entity,
1234
1234
  ...entityToMerge
1235
1235
  });
1236
1236
  return Promise.resolve({
1237
1237
  date: /* @__PURE__ */ new Date(),
1238
- etag: this.getEtag()
1238
+ etag: this.#getEtag()
1239
1239
  });
1240
1240
  }
1241
- withMetadata(entity) {
1241
+ #withMetadata(entity) {
1242
1242
  return {
1243
1243
  ...entity,
1244
- etag: this.getEtag()
1244
+ etag: this.#getEtag()
1245
1245
  };
1246
1246
  }
1247
1247
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-mock",
3
- "version": "2.28.0",
3
+ "version": "2.29.0",
4
4
  "description": "A library that contains azure mock classes.",
5
5
  "homepage": "https://github.com/Esposter/Esposter#readme",
6
6
  "bugs": {
@@ -23,7 +23,6 @@
23
23
  },
24
24
  "scripts": {
25
25
  "build": "pnpm export:gen && rolldown --config rolldown.config.ts",
26
- "coverage": "vitest run --coverage",
27
26
  "export:gen": "ctix build --config ../configuration/.ctirc-ts",
28
27
  "format": "oxfmt",
29
28
  "format:check": "oxfmt --check",
@@ -33,18 +32,18 @@
33
32
  "typecheck": "tsgo"
34
33
  },
35
34
  "dependencies": {
36
- "@esposter/db": "2.28.0",
37
- "@esposter/db-schema": "2.28.0",
38
- "@esposter/shared": "2.28.0",
35
+ "@esposter/db": "2.29.0",
36
+ "@esposter/db-schema": "2.29.0",
37
+ "@esposter/shared": "2.29.0",
39
38
  "fast-deep-equal": "^3.1.3"
40
39
  },
41
40
  "devDependencies": {
42
- "@esposter/configuration": "2.28.0",
43
- "@vitest/coverage-v8": "^4.1.8",
41
+ "@esposter/configuration": "2.29.0",
42
+ "@vitest/coverage-v8": "^4.1.9",
44
43
  "ctix": "^2.8.1",
45
- "rolldown": "^1.1.1",
44
+ "rolldown": "^1.1.2",
46
45
  "type-fest": "^5.7.0",
47
- "vitest": "^4.1.8"
46
+ "vitest": "^4.1.9"
48
47
  },
49
48
  "peerDependencies": {
50
49
  "@azure/core-http-compat": "^2.4.0",
@@ -55,5 +54,5 @@
55
54
  "@azure/storage-blob": "^12.32.0",
56
55
  "@azure/storage-queue": "^12.30.0"
57
56
  },
58
- "gitHead": "c633ee2d9e27aa520d3487a179982249463032a0"
57
+ "gitHead": "0166c5a9bea8b089ce37499f66b8d8095f4b4b23"
59
58
  }