@drakkar.software/sunglasses-adapter-starfish 0.5.0 → 0.6.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/dist/index.d.mts CHANGED
@@ -12,6 +12,12 @@ export { CleanupConfig, StarfishAdapterConfig } from '@drakkar.software/sunglass
12
12
  * 4. On 409 Conflict (optimistic locking): pull again, re-merge, re-push
13
13
  * (iterative, not recursive, to prevent stack overflow under high contention)
14
14
  *
15
+ * ## Push-only mode (`pushOnly: true`)
16
+ * Skips the pull step entirely — events are pushed as a fresh document each time.
17
+ * Use for Starfish collections with `queueOnly: true` where pull always returns
18
+ * empty data and optimistic locking is not needed.
19
+ * On failure the adapter throws, keeping events in the local queue for retry.
20
+ *
15
21
  * ## Rotating path mode (`rotatePathOnSuccess: true`)
16
22
  * Each successful push creates a **new** Starfish document with an
17
23
  * auto-incrementing path suffix (e.g. `events-0001`, `events-0002`…).
@@ -31,6 +37,7 @@ declare class StarfishAnalyticsAdapter implements IAnalyticsAdapter {
31
37
  private readonly authToken;
32
38
  private readonly maxRetries;
33
39
  private readonly timeoutMs;
40
+ private readonly pushOnly;
34
41
  private readonly rotatePathOnSuccess;
35
42
  private readonly pathStorage;
36
43
  constructor(config: StarfishAdapterConfig & {
@@ -46,6 +53,11 @@ declare class StarfishAnalyticsAdapter implements IAnalyticsAdapter {
46
53
  */
47
54
  cleanupAfterFlush(delivered: ReadonlyArray<SunglassesEvent>, config: CleanupConfig): Promise<void>;
48
55
  private sendMerge;
56
+ /**
57
+ * Push a fresh document directly, no pull, no merge, no conflict detection.
58
+ * Throws on failure so SunglassesCore keeps events in queue for retry.
59
+ */
60
+ private sendPushOnly;
49
61
  /**
50
62
  * Push events to a new Starfish document each time.
51
63
  *
package/dist/index.d.ts CHANGED
@@ -12,6 +12,12 @@ export { CleanupConfig, StarfishAdapterConfig } from '@drakkar.software/sunglass
12
12
  * 4. On 409 Conflict (optimistic locking): pull again, re-merge, re-push
13
13
  * (iterative, not recursive, to prevent stack overflow under high contention)
14
14
  *
15
+ * ## Push-only mode (`pushOnly: true`)
16
+ * Skips the pull step entirely — events are pushed as a fresh document each time.
17
+ * Use for Starfish collections with `queueOnly: true` where pull always returns
18
+ * empty data and optimistic locking is not needed.
19
+ * On failure the adapter throws, keeping events in the local queue for retry.
20
+ *
15
21
  * ## Rotating path mode (`rotatePathOnSuccess: true`)
16
22
  * Each successful push creates a **new** Starfish document with an
17
23
  * auto-incrementing path suffix (e.g. `events-0001`, `events-0002`…).
@@ -31,6 +37,7 @@ declare class StarfishAnalyticsAdapter implements IAnalyticsAdapter {
31
37
  private readonly authToken;
32
38
  private readonly maxRetries;
33
39
  private readonly timeoutMs;
40
+ private readonly pushOnly;
34
41
  private readonly rotatePathOnSuccess;
35
42
  private readonly pathStorage;
36
43
  constructor(config: StarfishAdapterConfig & {
@@ -46,6 +53,11 @@ declare class StarfishAnalyticsAdapter implements IAnalyticsAdapter {
46
53
  */
47
54
  cleanupAfterFlush(delivered: ReadonlyArray<SunglassesEvent>, config: CleanupConfig): Promise<void>;
48
55
  private sendMerge;
56
+ /**
57
+ * Push a fresh document directly, no pull, no merge, no conflict detection.
58
+ * Throws on failure so SunglassesCore keeps events in queue for retry.
59
+ */
60
+ private sendPushOnly;
49
61
  /**
50
62
  * Push events to a new Starfish document each time.
51
63
  *
package/dist/index.js CHANGED
@@ -79,6 +79,7 @@ var StarfishAnalyticsAdapter = class {
79
79
  this.authToken = config.authToken ?? "";
80
80
  this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
81
81
  this.timeoutMs = config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
82
+ this.pushOnly = config.pushOnly ?? false;
82
83
  this.rotatePathOnSuccess = config.rotatePathOnSuccess ?? false;
83
84
  this.pathStorage = config.pathStorage ?? null;
84
85
  if (this.rotatePathOnSuccess && !this.pathStorage) {
@@ -96,6 +97,9 @@ var StarfishAnalyticsAdapter = class {
96
97
  );
97
98
  }
98
99
  const baseResolved = resolveStoragePath(this.storagePath, identity);
100
+ if (this.pushOnly) {
101
+ return this.sendPushOnly(batch, baseResolved);
102
+ }
99
103
  if (this.rotatePathOnSuccess && this.pathStorage) {
100
104
  return this.sendRotating(batch, identity, baseResolved);
101
105
  }
@@ -167,6 +171,20 @@ var StarfishAnalyticsAdapter = class {
167
171
  `[SunGlasses] StarfishAnalyticsAdapter: max retries (${this.maxRetries}) exceeded for path "${path}" \u2014 batch discarded`
168
172
  );
169
173
  }
174
+ // ── Private: push-only mode (queueOnly collections) ──────────────────────
175
+ /**
176
+ * Push a fresh document directly, no pull, no merge, no conflict detection.
177
+ * Throws on failure so SunglassesCore keeps events in queue for retry.
178
+ */
179
+ async sendPushOnly(batch, path) {
180
+ const doc = mergeEvents(createEmptyDocument(), batch);
181
+ const response = await this.push(path, doc, "");
182
+ if (!response.ok) {
183
+ throw new Error(
184
+ `[SunGlasses] StarfishAnalyticsAdapter: push-only push failed with status ${response.status} for path "${path}"`
185
+ );
186
+ }
187
+ }
170
188
  // ── Private: rotating path mode ────────────────────────────────────────────
171
189
  /**
172
190
  * Push events to a new Starfish document each time.
package/dist/index.mjs CHANGED
@@ -49,6 +49,7 @@ var StarfishAnalyticsAdapter = class {
49
49
  this.authToken = config.authToken ?? "";
50
50
  this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
51
51
  this.timeoutMs = config.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
52
+ this.pushOnly = config.pushOnly ?? false;
52
53
  this.rotatePathOnSuccess = config.rotatePathOnSuccess ?? false;
53
54
  this.pathStorage = config.pathStorage ?? null;
54
55
  if (this.rotatePathOnSuccess && !this.pathStorage) {
@@ -66,6 +67,9 @@ var StarfishAnalyticsAdapter = class {
66
67
  );
67
68
  }
68
69
  const baseResolved = resolveStoragePath(this.storagePath, identity);
70
+ if (this.pushOnly) {
71
+ return this.sendPushOnly(batch, baseResolved);
72
+ }
69
73
  if (this.rotatePathOnSuccess && this.pathStorage) {
70
74
  return this.sendRotating(batch, identity, baseResolved);
71
75
  }
@@ -137,6 +141,20 @@ var StarfishAnalyticsAdapter = class {
137
141
  `[SunGlasses] StarfishAnalyticsAdapter: max retries (${this.maxRetries}) exceeded for path "${path}" \u2014 batch discarded`
138
142
  );
139
143
  }
144
+ // ── Private: push-only mode (queueOnly collections) ──────────────────────
145
+ /**
146
+ * Push a fresh document directly, no pull, no merge, no conflict detection.
147
+ * Throws on failure so SunglassesCore keeps events in queue for retry.
148
+ */
149
+ async sendPushOnly(batch, path) {
150
+ const doc = mergeEvents(createEmptyDocument(), batch);
151
+ const response = await this.push(path, doc, "");
152
+ if (!response.ok) {
153
+ throw new Error(
154
+ `[SunGlasses] StarfishAnalyticsAdapter: push-only push failed with status ${response.status} for path "${path}"`
155
+ );
156
+ }
157
+ }
140
158
  // ── Private: rotating path mode ────────────────────────────────────────────
141
159
  /**
142
160
  * Push events to a new Starfish document each time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drakkar.software/sunglasses-adapter-starfish",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Starfish document-sync adapter for SunGlasses (Drakkar-Software/Starfish)",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -16,7 +16,7 @@
16
16
  "dist"
17
17
  ],
18
18
  "dependencies": {
19
- "@drakkar.software/sunglasses-core": "0.5.0"
19
+ "@drakkar.software/sunglasses-core": "0.6.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "tsup": "^8.3.5",