@7365admin1/module-hygiene 4.27.1 → 4.27.2-staging.4

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.
@@ -0,0 +1,36 @@
1
+ name: Publish Staging
2
+ on:
3
+ push:
4
+ branches:
5
+ - staging
6
+
7
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20.x
18
+ cache: "yarn"
19
+ cache-dependency-path: yarn.lock
20
+
21
+ - run: yarn install --immutable
22
+
23
+ - run: yarn build
24
+
25
+ - name: Create .npmrc for publishing
26
+ run: |
27
+ echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' > ~/.npmrc
28
+
29
+ - name: Set staging prerelease version
30
+ run: |
31
+ BASE=$(node -p "const [x,y,z]=require('./package.json').version.split('-')[0].split('.'); [x,y,+z+1].join('.')")
32
+ npm version "$BASE-staging.${{ github.run_number }}" --no-git-tag-version
33
+ node -p "'Publishing ' + require('./package.json').version"
34
+
35
+ - name: Publish to npm with staging tag
36
+ run: npm publish --tag staging --registry https://registry.npmjs.org
package/dist/index.js CHANGED
@@ -3314,7 +3314,19 @@ function useAreaChecklistRepo() {
3314
3314
  }
3315
3315
  async function createUniqueIndex() {
3316
3316
  try {
3317
- await collection.createIndex({ schedule: 1, area: 1 }, { unique: true });
3317
+ await collection.createIndex(
3318
+ { schedule: 1, area: 1, serviceType: 1 },
3319
+ { unique: true }
3320
+ );
3321
+ const legacyIndex = (await collection.indexes()).find((index) => {
3322
+ return index.unique === true && JSON.stringify(index.key) === JSON.stringify({ schedule: 1, area: 1 });
3323
+ });
3324
+ if (legacyIndex?.name) {
3325
+ await collection.dropIndex(legacyIndex.name);
3326
+ import_node_server_utils17.logger.info(
3327
+ `Dropped legacy hygiene area checklist unique index: ${legacyIndex.name}`
3328
+ );
3329
+ }
3318
3330
  } catch (error) {
3319
3331
  throw new import_node_server_utils17.InternalServerError(
3320
3332
  "Failed to create unique index on hygiene checklist area."
@@ -3326,7 +3338,7 @@ function useAreaChecklistRepo() {
3326
3338
  const parentChecklistId = new import_mongodb9.ObjectId(value.schedule);
3327
3339
  const areaId = new import_mongodb9.ObjectId(value.area);
3328
3340
  const existingChecklist = await collection.findOne(
3329
- { schedule: parentChecklistId, area: areaId },
3341
+ { schedule: parentChecklistId, area: areaId, serviceType: value.serviceType },
3330
3342
  { session }
3331
3343
  );
3332
3344
  if (existingChecklist) {
@@ -3344,7 +3356,8 @@ function useAreaChecklistRepo() {
3344
3356
  import_node_server_utils17.logger.info(`Duplicate area checklist skipped for area ${value.name}`);
3345
3357
  const existing = await collection.findOne({
3346
3358
  schedule: new import_mongodb9.ObjectId(value.schedule),
3347
- area: new import_mongodb9.ObjectId(value.area)
3359
+ area: new import_mongodb9.ObjectId(value.area),
3360
+ serviceType: value.serviceType
3348
3361
  });
3349
3362
  return existing._id;
3350
3363
  }
@@ -5180,9 +5193,18 @@ function useSupplyRepository() {
5180
5193
  async function createUniqueIndex() {
5181
5194
  try {
5182
5195
  await collection.createIndex(
5183
- { site: 1, name: 1, deletedAt: 1 },
5196
+ { site: 1, serviceType: 1, name: 1, deletedAt: 1 },
5184
5197
  { unique: true }
5185
5198
  );
5199
+ const legacyIndex = (await collection.indexes()).find((index) => {
5200
+ return index.unique === true && JSON.stringify(index.key) === JSON.stringify({ site: 1, name: 1, deletedAt: 1 });
5201
+ });
5202
+ if (legacyIndex?.name) {
5203
+ await collection.dropIndex(legacyIndex.name);
5204
+ import_node_server_utils22.logger.info(
5205
+ `Dropped legacy hygiene supply unique index: ${legacyIndex.name}`
5206
+ );
5207
+ }
5186
5208
  } catch (error) {
5187
5209
  throw new import_node_server_utils22.InternalServerError(
5188
5210
  "Failed to create unique index on hygiene supply."