@adcp/reporting-storage 0.0.0-stage → 0.1.0-beta.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/LICENSE +191 -0
- package/README.md +97 -2
- package/dist/azure/index.d.mts +31 -0
- package/dist/azure/index.d.ts +31 -0
- package/dist/azure/index.js +308 -0
- package/dist/azure/index.mjs +291 -0
- package/dist/bigquery/index.d.mts +247 -0
- package/dist/bigquery/index.d.ts +247 -0
- package/dist/bigquery/index.js +633 -0
- package/dist/bigquery/index.mjs +594 -0
- package/dist/change-feed.d.mts +84 -0
- package/dist/change-feed.d.ts +84 -0
- package/dist/change-feed.js +157 -0
- package/dist/change-feed.mjs +129 -0
- package/dist/gcs/adapter.d.mts +38 -0
- package/dist/gcs/adapter.d.ts +38 -0
- package/dist/gcs/adapter.js +342 -0
- package/dist/gcs/adapter.mjs +325 -0
- package/dist/gcs/bucket-policy.d.mts +3 -0
- package/dist/gcs/bucket-policy.d.ts +3 -0
- package/dist/gcs/bucket-policy.js +31 -0
- package/dist/gcs/bucket-policy.mjs +7 -0
- package/dist/gcs/errors.d.mts +11 -0
- package/dist/gcs/errors.d.ts +11 -0
- package/dist/gcs/errors.js +41 -0
- package/dist/gcs/errors.mjs +16 -0
- package/dist/gcs/fence.d.mts +41 -0
- package/dist/gcs/fence.d.ts +41 -0
- package/dist/gcs/fence.js +250 -0
- package/dist/gcs/fence.mjs +230 -0
- package/dist/gcs/index.d.mts +18 -0
- package/dist/gcs/index.d.ts +18 -0
- package/dist/gcs/index.js +44 -0
- package/dist/gcs/index.mjs +14 -0
- package/dist/gcs/io.d.mts +7 -0
- package/dist/gcs/io.d.ts +7 -0
- package/dist/gcs/io.js +95 -0
- package/dist/gcs/io.mjs +69 -0
- package/dist/gcs/reader.d.mts +67 -0
- package/dist/gcs/reader.d.ts +67 -0
- package/dist/gcs/reader.js +193 -0
- package/dist/gcs/reader.mjs +169 -0
- package/dist/gcs/row-provider.d.mts +39 -0
- package/dist/gcs/row-provider.d.ts +39 -0
- package/dist/gcs/row-provider.js +266 -0
- package/dist/gcs/row-provider.mjs +249 -0
- package/dist/gcs/validation.d.mts +5 -0
- package/dist/gcs/validation.d.ts +5 -0
- package/dist/gcs/validation.js +49 -0
- package/dist/gcs/validation.mjs +25 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +34 -0
- package/dist/index.mjs +7 -0
- package/dist/maintenance.d.mts +243 -0
- package/dist/maintenance.d.ts +243 -0
- package/dist/maintenance.js +328 -0
- package/dist/maintenance.mjs +301 -0
- package/dist/managed/index.d.mts +12 -0
- package/dist/managed/index.d.ts +12 -0
- package/dist/managed/index.js +26 -0
- package/dist/managed/index.mjs +3 -0
- package/dist/managed/postgres.d.mts +275 -0
- package/dist/managed/postgres.d.ts +275 -0
- package/dist/managed/postgres.js +2345 -0
- package/dist/managed/postgres.mjs +2336 -0
- package/dist/managed/router.d.mts +148 -0
- package/dist/managed/router.d.ts +148 -0
- package/dist/managed/router.js +280 -0
- package/dist/managed/router.mjs +258 -0
- package/dist/managed/runtime.d.mts +500 -0
- package/dist/managed/runtime.d.ts +500 -0
- package/dist/managed/runtime.js +604 -0
- package/dist/managed/runtime.mjs +578 -0
- package/dist/notifications/index.d.mts +10 -0
- package/dist/notifications/index.d.ts +10 -0
- package/dist/notifications/index.js +22 -0
- package/dist/notifications/index.mjs +1 -0
- package/dist/notifications/notification-activity.d.mts +331 -0
- package/dist/notifications/notification-activity.d.ts +331 -0
- package/dist/notifications/notification-activity.js +1366 -0
- package/dist/notifications/notification-activity.mjs +1337 -0
- package/dist/object-writes.d.mts +128 -0
- package/dist/object-writes.d.ts +128 -0
- package/dist/object-writes.js +147 -0
- package/dist/object-writes.mjs +114 -0
- package/dist/postgres.d.mts +808 -0
- package/dist/postgres.d.ts +808 -0
- package/dist/postgres.js +4711 -0
- package/dist/postgres.mjs +4723 -0
- package/dist/row-storage-migration.d.mts +59 -0
- package/dist/row-storage-migration.d.ts +59 -0
- package/dist/row-storage-migration.js +365 -0
- package/dist/row-storage-migration.mjs +339 -0
- package/dist/row-storage-object.d.mts +244 -0
- package/dist/row-storage-object.d.ts +244 -0
- package/dist/row-storage-object.js +539 -0
- package/dist/row-storage-object.mjs +495 -0
- package/dist/row-storage-provider-io.d.mts +51 -0
- package/dist/row-storage-provider-io.d.ts +51 -0
- package/dist/row-storage-provider-io.js +154 -0
- package/dist/row-storage-provider-io.mjs +121 -0
- package/dist/row-storage.d.mts +341 -0
- package/dist/row-storage.d.ts +341 -0
- package/dist/row-storage.js +867 -0
- package/dist/row-storage.mjs +862 -0
- package/dist/s3/index.d.mts +34 -0
- package/dist/s3/index.d.ts +34 -0
- package/dist/s3/index.js +409 -0
- package/dist/s3/index.mjs +403 -0
- package/dist/service/index.d.mts +163 -0
- package/dist/service/index.d.ts +163 -0
- package/dist/service/index.js +390 -0
- package/dist/service/index.mjs +396 -0
- package/examples/reliable-reporting-service/README.md +169 -0
- package/package.json +188 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2025 AgenticAdvertising.Org
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @adcp/reporting-storage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Storage for AdCP Reliable Reporting. It holds the implementations that sit behind the protocol layer in
|
|
4
|
+
[`@adcp/sdk`](https://www.npmjs.com/package/@adcp/sdk): the PostgreSQL ledger store, revision row storage with GCS, S3
|
|
5
|
+
and Azure Blob providers, managed delivery, notification activity, the BigQuery warehouse sink, and the production
|
|
6
|
+
composition that wires them together.
|
|
7
|
+
|
|
8
|
+
This package is **pre-1.0 and every export is `@experimental`**: breaking changes ship in minor releases, announced in
|
|
9
|
+
the changelog with a migration note. Pin it with `~` (`~0.1.0-beta.0` while in beta, `~0.1.0` after a stable release). See the
|
|
10
|
+
[stability policy](https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# While SDK 16 is in beta, both packages come from the `beta` dist-tag. Drop `@beta` once stable releases exist.
|
|
16
|
+
npm install @adcp/sdk@beta @adcp/reporting-storage@beta pg
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`@adcp/sdk` is a **peer dependency** (the SDK 16 line). The store, its errors and the protocol handlers share types and
|
|
20
|
+
symbol-keyed guards, so the host must have exactly one copy of it. Install the pair that was published together: each
|
|
21
|
+
release raises the peer floor to the SDK it was built against. The cloud SDKs are optional peers: install only the
|
|
22
|
+
ones you use.
|
|
23
|
+
|
|
24
|
+
| You use | Also install |
|
|
25
|
+
| -------------------------- | ------------------------------- |
|
|
26
|
+
| `@adcp/reporting-storage/gcs` | `@google-cloud/storage` (`^7.22.0 \|\| ^8.2.0`) |
|
|
27
|
+
| `@adcp/reporting-storage/s3` | `@aws-sdk/client-s3` (`^3.700.0`) |
|
|
28
|
+
| `@adcp/reporting-storage/azure` | `@azure/storage-blob` (`^12.23.0`) |
|
|
29
|
+
| `@adcp/reporting-storage/bigquery` | `@google-cloud/bigquery` (you pass the client in) |
|
|
30
|
+
|
|
31
|
+
## Subpaths
|
|
32
|
+
|
|
33
|
+
| Import | What it holds |
|
|
34
|
+
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
35
|
+
| `@adcp/reporting-storage` | `PostgresReportingLedgerStore` and its migrations, row storage, object writes, the host change feed, maintenance |
|
|
36
|
+
| `@adcp/reporting-storage/managed` | managed-delivery runtime, `PostgresReportingManagedDeliveryStore`, the adapter contract and router |
|
|
37
|
+
| `@adcp/reporting-storage/notifications` | notification activity stores, checkpoints and runtime |
|
|
38
|
+
| `@adcp/reporting-storage/service` | `createPostgresReliableReportingProductionService` |
|
|
39
|
+
| `@adcp/reporting-storage/gcs` | GCS fence, reader, managed-delivery adapter and row-object provider |
|
|
40
|
+
| `@adcp/reporting-storage/s3` | S3 row-object provider |
|
|
41
|
+
| `@adcp/reporting-storage/azure` | Azure Blob row-object provider |
|
|
42
|
+
| `@adcp/reporting-storage/bigquery` | BigQuery warehouse sink |
|
|
43
|
+
|
|
44
|
+
The protocol layer stays in `@adcp/sdk`: the `ReportingLedgerStore` interface, the protocol handlers, the producer,
|
|
45
|
+
`createReliableReportingService`, row encoding and digests, `@adcp/sdk/reporting/consumer` and `@adcp/sdk/reporting/source`.
|
|
46
|
+
|
|
47
|
+
## Apply migrations in this order
|
|
48
|
+
|
|
49
|
+
Migrations are idempotent SQL strings. Apply them to the ledger database with your migration tool, in this order, and
|
|
50
|
+
only the ones whose feature you turn on.
|
|
51
|
+
|
|
52
|
+
| Order | Constant | Import | Needed for |
|
|
53
|
+
| ----- | ------------------------------------------------------- | --------------------------------------- | --------------------------------------- |
|
|
54
|
+
| 1 | `REPORTING_LEDGER_MIGRATION` | `@adcp/reporting-storage` | always |
|
|
55
|
+
| 2 | `REPORTING_LEDGER_FINALITY_WRITER_FENCE_MIGRATION` | `@adcp/reporting-storage` | the finality writer fence |
|
|
56
|
+
| 3 | `REPORTING_ROW_STORAGE_MIGRATION` | `@adcp/reporting-storage` | `rowStorage` (PostgreSQL 13+) |
|
|
57
|
+
| 4 | `REPORTING_LEDGER_CHANGES_MIGRATION` | `@adcp/reporting-storage` | `changeFeed: true` (PostgreSQL 13+) |
|
|
58
|
+
| 5 | `REPORTING_MANAGED_DELIVERY_MIGRATION` | `@adcp/reporting-storage/managed` | managed delivery |
|
|
59
|
+
| 6 | `REPORTING_OBJECT_WRITE_MIGRATION`, `REPORTING_OBJECT_WRITE_AUTHORITY_MIGRATION` | `@adcp/reporting-storage` | the GCS write fence |
|
|
60
|
+
| 7 | `REPORTING_NOTIFICATION_ACTIVITY_MIGRATION` | `@adcp/reporting-storage/notifications` | notification activity |
|
|
61
|
+
| 8 | `REPORTING_WAREHOUSE_SINK_MIGRATION` | `@adcp/reporting-storage/bigquery` | the BigQuery sink (after the change feed) |
|
|
62
|
+
|
|
63
|
+
`createPostgresReliableReportingProductionService` returns the ordered list it needs as `service.setup.migrations`, and
|
|
64
|
+
`applyMigrations` bridges it into your runner.
|
|
65
|
+
|
|
66
|
+
## Which import?
|
|
67
|
+
|
|
68
|
+
| You want | Import from |
|
|
69
|
+
| --------------------------------------------------------------- | ------------------------------------------ |
|
|
70
|
+
| The Core service (`createReliableReportingService`) | `@adcp/sdk/reporting/service` |
|
|
71
|
+
| The whole seller chain on PostgreSQL (`createPostgresReliableReportingProductionService`) | `@adcp/reporting-storage/service` |
|
|
72
|
+
| The protocol handlers, producer and the `ReportingLedgerStore` interface | `@adcp/sdk/reporting/ledger` |
|
|
73
|
+
| The PostgreSQL ledger store and the `maintenance` factory | `@adcp/reporting-storage` |
|
|
74
|
+
|
|
75
|
+
## Use
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { Pool } from 'pg';
|
|
79
|
+
import { createReliableReportingService } from '@adcp/sdk/reporting/service';
|
|
80
|
+
import { PostgresReportingLedgerStore, REPORTING_LEDGER_MIGRATION, reportingLedgerMaintenance } from '@adcp/reporting-storage';
|
|
81
|
+
|
|
82
|
+
const pool = new Pool({ connectionString: process.env.REPORTING_LEDGER_URL });
|
|
83
|
+
await pool.query(REPORTING_LEDGER_MIGRATION);
|
|
84
|
+
|
|
85
|
+
const store = new PostgresReportingLedgerStore(pool, { acknowledgeIsolatedDatabase: true });
|
|
86
|
+
const reporting = createReliableReportingService({
|
|
87
|
+
store,
|
|
88
|
+
// ...adapters, contact, retention commitments, resolvers
|
|
89
|
+
maintenance: reportingLedgerMaintenance({ retention: { enabled: true } }),
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
For the full chain (managed delivery, notifications, one scheduler) use `createPostgresReliableReportingProductionService`
|
|
94
|
+
from `@adcp/reporting-storage/service`.
|
|
95
|
+
|
|
96
|
+
- [Seller reporting ledger](https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-LEDGER.md)
|
|
97
|
+
- [Production operations](https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-OPERATIONS.md)
|
|
98
|
+
- [Migrating from `@adcp/sdk/reporting/*`](https://github.com/adcontextprotocol/adcp-client/blob/main/docs/migration-reporting-storage-package.md)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BlobServiceClient } from '@azure/storage-blob';
|
|
2
|
+
import type { ReportingRowObjectProviderV1 } from '../row-storage-object.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
5
|
+
*/
|
|
6
|
+
export interface CreateAzureBlobReportingRowObjectProviderOptionsV1 {
|
|
7
|
+
/** Official client used by bindings without a `credentialRef`. */
|
|
8
|
+
client?: BlobServiceClient;
|
|
9
|
+
/**
|
|
10
|
+
* Official clients keyed by `credentialRef`. This map is the closed set of
|
|
11
|
+
* references a binding may name; an unknown reference fails `UNSAFE_BINDING`.
|
|
12
|
+
* Endpoint and credentials come only from these clients.
|
|
13
|
+
*/
|
|
14
|
+
clients?: Readonly<Record<string, BlobServiceClient>>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Azure Blob Storage row-object provider (`@adcp/reporting-storage/azure`).
|
|
18
|
+
*
|
|
19
|
+
* Inject official `BlobServiceClient`s with host-owned credentials (managed
|
|
20
|
+
* identity, workload identity). Bindings use `location: { account, container }`;
|
|
21
|
+
* the selected client must belong to `account`. Writes are block-blob uploads
|
|
22
|
+
* with `If-None-Match: *`. Blob versioning must be enabled on the storage account:
|
|
23
|
+
* the recorded native version is the write-unique `versionId` and pins every read
|
|
24
|
+
* and delete, so a delayed delete can never remove a later write that re-created
|
|
25
|
+
* identical bytes at the same key (ETags are content-derived and cannot fence that).
|
|
26
|
+
* The probe refuses accounts without versioning and proves create-only behaviour
|
|
27
|
+
* empirically.
|
|
28
|
+
*
|
|
29
|
+
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAzureBlobReportingRowObjectProviderV1(options: CreateAzureBlobReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BlobServiceClient } from '@azure/storage-blob';
|
|
2
|
+
import type { ReportingRowObjectProviderV1 } from '../row-storage-object';
|
|
3
|
+
/**
|
|
4
|
+
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
5
|
+
*/
|
|
6
|
+
export interface CreateAzureBlobReportingRowObjectProviderOptionsV1 {
|
|
7
|
+
/** Official client used by bindings without a `credentialRef`. */
|
|
8
|
+
client?: BlobServiceClient;
|
|
9
|
+
/**
|
|
10
|
+
* Official clients keyed by `credentialRef`. This map is the closed set of
|
|
11
|
+
* references a binding may name; an unknown reference fails `UNSAFE_BINDING`.
|
|
12
|
+
* Endpoint and credentials come only from these clients.
|
|
13
|
+
*/
|
|
14
|
+
clients?: Readonly<Record<string, BlobServiceClient>>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Azure Blob Storage row-object provider (`@adcp/reporting-storage/azure`).
|
|
18
|
+
*
|
|
19
|
+
* Inject official `BlobServiceClient`s with host-owned credentials (managed
|
|
20
|
+
* identity, workload identity). Bindings use `location: { account, container }`;
|
|
21
|
+
* the selected client must belong to `account`. Writes are block-blob uploads
|
|
22
|
+
* with `If-None-Match: *`. Blob versioning must be enabled on the storage account:
|
|
23
|
+
* the recorded native version is the write-unique `versionId` and pins every read
|
|
24
|
+
* and delete, so a delayed delete can never remove a later write that re-created
|
|
25
|
+
* identical bytes at the same key (ETags are content-derived and cannot fence that).
|
|
26
|
+
* The probe refuses accounts without versioning and proves create-only behaviour
|
|
27
|
+
* empirically.
|
|
28
|
+
*
|
|
29
|
+
* @experimental Reliable Reporting storage surface: breaking changes may ship in minor releases. See https://github.com/adcontextprotocol/adcp-client/blob/main/docs/guides/REPORTING-STABILITY.md
|
|
30
|
+
*/
|
|
31
|
+
export declare function createAzureBlobReportingRowObjectProviderV1(options: CreateAzureBlobReportingRowObjectProviderOptionsV1): ReportingRowObjectProviderV1;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var azure_exports = {};
|
|
20
|
+
__export(azure_exports, {
|
|
21
|
+
createAzureBlobReportingRowObjectProviderV1: () => createAzureBlobReportingRowObjectProviderV1
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(azure_exports);
|
|
24
|
+
var import_node_crypto = require("node:crypto");
|
|
25
|
+
var import_ledger = require("@adcp/sdk/reporting/ledger");
|
|
26
|
+
var import_row_storage_provider_io = require('../row-storage-provider-io.js');
|
|
27
|
+
const ACCOUNT = /^[a-z0-9]{3,24}$/;
|
|
28
|
+
const CONTAINER = /^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){2,62}$/;
|
|
29
|
+
const VERSION_ID = /^[0-9A-Za-z:.+-]{1,64}$/;
|
|
30
|
+
function statusOf(error) {
|
|
31
|
+
const status = Number(error?.statusCode);
|
|
32
|
+
return Number.isInteger(status) ? status : void 0;
|
|
33
|
+
}
|
|
34
|
+
function codeOf(error) {
|
|
35
|
+
const value = error?.code ?? error?.details?.errorCode;
|
|
36
|
+
return typeof value === "string" ? value : "";
|
|
37
|
+
}
|
|
38
|
+
const isConflict = (error) => statusOf(error) === 409 || statusOf(error) === 412 || codeOf(error) === "BlobAlreadyExists";
|
|
39
|
+
const isMissing = (error) => statusOf(error) === 404 || statusOf(error) === 412;
|
|
40
|
+
const isForbidden = (error) => statusOf(error) === 401 || statusOf(error) === 403;
|
|
41
|
+
function versionOf(response) {
|
|
42
|
+
const id = response.versionId;
|
|
43
|
+
if (typeof id !== "string" || !VERSION_ID.test(id)) {
|
|
44
|
+
throw new import_ledger.ReportingRowStoreError(
|
|
45
|
+
"UNSAFE_BINDING",
|
|
46
|
+
"store returned no blob versionId; blob versioning must be enabled on the storage account so deletes are fenced to one write"
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return id;
|
|
50
|
+
}
|
|
51
|
+
function servedVersion(response, versionId) {
|
|
52
|
+
return response.versionId === versionId;
|
|
53
|
+
}
|
|
54
|
+
function metadataOf(metadata) {
|
|
55
|
+
const result = {};
|
|
56
|
+
for (const [name, value] of Object.entries(metadata)) {
|
|
57
|
+
const identifier = name.replace(/[^A-Za-z0-9_]/g, "_");
|
|
58
|
+
result[/^[A-Za-z_]/.test(identifier) ? identifier : `_${identifier}`] = value;
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
function createAzureBlobReportingRowObjectProviderV1(options) {
|
|
63
|
+
if (!options || typeof options !== "object") {
|
|
64
|
+
throw new import_ledger.ReportingRowStoreError("INVALID_INPUT", "Azure Blob row provider options are required");
|
|
65
|
+
}
|
|
66
|
+
const clients = (0, import_row_storage_provider_io.reportingRowClientMap)(options.clients);
|
|
67
|
+
const isClient = (value) => !!value && typeof value === "object" && typeof value.getContainerClient === "function" && typeof value.accountName === "string";
|
|
68
|
+
if (options.client !== void 0 && !isClient(options.client) || [...clients.values()].some((client) => !isClient(client)) || options.client === void 0 && clients.size === 0) {
|
|
69
|
+
throw new import_ledger.ReportingRowStoreError("INVALID_INPUT", "inject an official BlobServiceClient as client or clients");
|
|
70
|
+
}
|
|
71
|
+
const validateLocation = (location) => {
|
|
72
|
+
(0, import_row_storage_provider_io.assertReportingRowLocationKeys)(location, ["account", "container"]);
|
|
73
|
+
if (!ACCOUNT.test(location.account)) {
|
|
74
|
+
throw new import_ledger.ReportingRowStoreError("INVALID_INPUT", "Azure storage account name is invalid");
|
|
75
|
+
}
|
|
76
|
+
if (!CONTAINER.test(location.container)) {
|
|
77
|
+
throw new import_ledger.ReportingRowStoreError("INVALID_INPUT", "Azure container name is invalid");
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const containerFor = (input) => {
|
|
81
|
+
validateLocation(input.location);
|
|
82
|
+
const client = (0, import_row_storage_provider_io.selectReportingRowClient)(options.client, clients, input.credentialRef);
|
|
83
|
+
if (client.accountName !== input.location.account) {
|
|
84
|
+
throw new import_ledger.ReportingRowStoreError("UNSAFE_BINDING", "client does not belong to the binding account");
|
|
85
|
+
}
|
|
86
|
+
return client.getContainerClient(input.location.container);
|
|
87
|
+
};
|
|
88
|
+
const blobFor = (input) => {
|
|
89
|
+
if (typeof input.objectRef !== "string" || input.objectRef.length === 0 || input.objectRef.length > 1024) {
|
|
90
|
+
throw new import_ledger.ReportingRowStoreError("INVALID_INPUT", "object key is invalid");
|
|
91
|
+
}
|
|
92
|
+
return containerFor(input).getBlockBlobClient(input.objectRef);
|
|
93
|
+
};
|
|
94
|
+
const pinned = (blob, nativeVersionRef) => typeof nativeVersionRef === "string" && VERSION_ID.test(nativeVersionRef) ? { blob: blob.withVersion(nativeVersionRef), versionId: nativeVersionRef } : null;
|
|
95
|
+
async function assertCreateOnlyEnforced(container, prefix, signal) {
|
|
96
|
+
const blob = container.getBlockBlobClient(`${prefix}/.adcp-probe/${(0, import_node_crypto.randomUUID)()}`);
|
|
97
|
+
const versionIds = [];
|
|
98
|
+
let written = false;
|
|
99
|
+
const upload = async (body) => {
|
|
100
|
+
const bytes = Buffer.from(body);
|
|
101
|
+
const response = await blob.upload(bytes, bytes.byteLength, {
|
|
102
|
+
conditions: { ifNoneMatch: "*" },
|
|
103
|
+
blobHTTPHeaders: { blobContentType: "application/x-ndjson", blobCacheControl: "no-store" },
|
|
104
|
+
abortSignal: signal
|
|
105
|
+
});
|
|
106
|
+
written = true;
|
|
107
|
+
if (response.versionId) versionIds.push(response.versionId);
|
|
108
|
+
versionOf(response);
|
|
109
|
+
};
|
|
110
|
+
try {
|
|
111
|
+
await upload('{"probe":1}\n');
|
|
112
|
+
try {
|
|
113
|
+
await upload('{"probe":2}\n');
|
|
114
|
+
} catch (error) {
|
|
115
|
+
if (isConflict(error)) return;
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
throw new import_ledger.ReportingRowStoreError("UNSAFE_BINDING", "store ignores If-None-Match and replaces blobs");
|
|
119
|
+
} finally {
|
|
120
|
+
if (written && !signal.aborted) {
|
|
121
|
+
await blob.delete({ abortSignal: signal }).catch(() => void 0);
|
|
122
|
+
for (const versionId of versionIds) {
|
|
123
|
+
if (signal.aborted) break;
|
|
124
|
+
await blob.withVersion(versionId).delete({ abortSignal: signal }).catch(() => void 0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
name: "azure_blob",
|
|
131
|
+
rangedReads: true,
|
|
132
|
+
validateLocation,
|
|
133
|
+
probe(input, context) {
|
|
134
|
+
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
135
|
+
const container = containerFor(input);
|
|
136
|
+
let properties;
|
|
137
|
+
try {
|
|
138
|
+
properties = await container.getProperties({ abortSignal: context.signal });
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (statusOf(error) === 404) throw new import_ledger.ReportingRowStoreError("UNSAFE_BINDING", "container does not exist");
|
|
141
|
+
if (isForbidden(error)) throw new import_ledger.ReportingRowStoreError("UNSAFE_BINDING", "container is not accessible");
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
if (properties.blobPublicAccess) {
|
|
145
|
+
throw new import_ledger.ReportingRowStoreError("UNSAFE_BINDING", "container allows anonymous read access");
|
|
146
|
+
}
|
|
147
|
+
await assertCreateOnlyEnforced(container, input.prefix, context.signal);
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
putIfAbsent(input, context) {
|
|
151
|
+
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
152
|
+
const blob = blobFor(input);
|
|
153
|
+
const bytes = Buffer.from(input.bytes);
|
|
154
|
+
try {
|
|
155
|
+
const response = await blob.upload(bytes, bytes.byteLength, {
|
|
156
|
+
conditions: { ifNoneMatch: "*" },
|
|
157
|
+
blobHTTPHeaders: { blobContentType: input.contentType, blobCacheControl: "no-store" },
|
|
158
|
+
metadata: metadataOf(input.metadata),
|
|
159
|
+
abortSignal: context.signal
|
|
160
|
+
});
|
|
161
|
+
return { created: true, nativeVersionRef: versionOf(response) };
|
|
162
|
+
} catch (error) {
|
|
163
|
+
if (!isConflict(error)) throw error;
|
|
164
|
+
}
|
|
165
|
+
const existing = await blob.getProperties({ abortSignal: context.signal });
|
|
166
|
+
return { created: false, nativeVersionRef: versionOf(existing) };
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
get(input, context) {
|
|
170
|
+
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
171
|
+
const blob = blobFor(input);
|
|
172
|
+
(0, import_row_storage_provider_io.assertReportingRowReadBounds)(input);
|
|
173
|
+
const target = pinned(blob, input.nativeVersionRef);
|
|
174
|
+
if (target === null) return null;
|
|
175
|
+
try {
|
|
176
|
+
if (input.range?.length === 0) {
|
|
177
|
+
const properties = await target.blob.getProperties({ abortSignal: context.signal });
|
|
178
|
+
if (!servedVersion(properties, target.versionId)) return null;
|
|
179
|
+
if (input.range.offset > Number(properties.contentLength ?? 0)) {
|
|
180
|
+
throw new import_ledger.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "requested range exceeds the stored object");
|
|
181
|
+
}
|
|
182
|
+
return Buffer.alloc(0);
|
|
183
|
+
}
|
|
184
|
+
const response = await target.blob.download(input.range?.offset ?? 0, input.range?.length, {
|
|
185
|
+
abortSignal: context.signal
|
|
186
|
+
});
|
|
187
|
+
const body = response.readableStreamBody;
|
|
188
|
+
if (!body || typeof body[Symbol.asyncIterator] !== "function") {
|
|
189
|
+
throw new import_ledger.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "blob body is not a stream");
|
|
190
|
+
}
|
|
191
|
+
if (!servedVersion(response, target.versionId)) {
|
|
192
|
+
body.destroy?.();
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
if (typeof response.contentLength === "number" && response.contentLength > input.maxBytes) {
|
|
196
|
+
body.destroy?.();
|
|
197
|
+
throw new import_ledger.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "stored object exceeds its recorded size");
|
|
198
|
+
}
|
|
199
|
+
return await (0, import_row_storage_provider_io.readReportingRowStream)(body, input.maxBytes, context.signal);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
if (isMissing(error)) return null;
|
|
202
|
+
if (statusOf(error) === 400) return null;
|
|
203
|
+
if (statusOf(error) === 416 || codeOf(error) === "InvalidRange") {
|
|
204
|
+
throw new import_ledger.ReportingRowStoreError("ROWS_INTEGRITY_FAILED", "requested range exceeds the stored object");
|
|
205
|
+
}
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
stat(input, context) {
|
|
211
|
+
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
212
|
+
const blob = blobFor(input);
|
|
213
|
+
const target = pinned(blob, input.nativeVersionRef);
|
|
214
|
+
if (target === null) return null;
|
|
215
|
+
try {
|
|
216
|
+
const properties = await target.blob.getProperties({ abortSignal: context.signal });
|
|
217
|
+
if (!servedVersion(properties, target.versionId)) return null;
|
|
218
|
+
const size = properties.contentLength;
|
|
219
|
+
if (typeof size !== "number" || !Number.isSafeInteger(size) || size < 0) {
|
|
220
|
+
throw new import_ledger.ReportingRowStoreError("PROVIDER_UNAVAILABLE", "blob metadata is malformed");
|
|
221
|
+
}
|
|
222
|
+
return { nativeVersionRef: target.versionId, sizeBytes: size };
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (isMissing(error) || statusOf(error) === 400) return null;
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
list(input, context) {
|
|
230
|
+
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
231
|
+
const container = containerFor(input);
|
|
232
|
+
if (typeof input.prefix !== "string" || input.prefix.length > 1024) {
|
|
233
|
+
throw new import_ledger.ReportingRowStoreError("INVALID_INPUT", "list prefix is invalid");
|
|
234
|
+
}
|
|
235
|
+
if (!Number.isSafeInteger(input.pageSize) || input.pageSize < 1) {
|
|
236
|
+
throw new import_ledger.ReportingRowStoreError("INVALID_INPUT", "pageSize must be a positive integer");
|
|
237
|
+
}
|
|
238
|
+
const pages = container.listBlobsFlat({ prefix: input.prefix, includeVersions: true, abortSignal: context.signal }).byPage({
|
|
239
|
+
maxPageSize: Math.min(input.pageSize, 5e3),
|
|
240
|
+
...input.pageToken ? { continuationToken: input.pageToken } : {}
|
|
241
|
+
});
|
|
242
|
+
const page = (await pages.next()).value;
|
|
243
|
+
const objects = [];
|
|
244
|
+
let skipped = 0;
|
|
245
|
+
for (const item of page?.segment?.blobItems ?? []) {
|
|
246
|
+
const size = item.properties?.contentLength;
|
|
247
|
+
const created = Math.max(
|
|
248
|
+
item.properties?.createdOn?.getTime() ?? NaN,
|
|
249
|
+
item.properties?.lastModified?.getTime() ?? 0
|
|
250
|
+
);
|
|
251
|
+
if (typeof item.name !== "string" || !item.name.startsWith(input.prefix) || typeof item.versionId !== "string" || !VERSION_ID.test(item.versionId) || typeof size !== "number" || !Number.isSafeInteger(size) || size < 0 || !Number.isFinite(created)) {
|
|
252
|
+
skipped += 1;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
objects.push({
|
|
256
|
+
objectRef: item.name,
|
|
257
|
+
nativeVersionRef: item.versionId,
|
|
258
|
+
sizeBytes: size,
|
|
259
|
+
createdAt: new Date(created).toISOString()
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
await pages.return?.(void 0);
|
|
263
|
+
const token = page?.continuationToken;
|
|
264
|
+
return {
|
|
265
|
+
objects,
|
|
266
|
+
...skipped > 0 ? { skipped } : {},
|
|
267
|
+
...typeof token === "string" && token ? { nextPageToken: token } : {}
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
delete(input, context) {
|
|
272
|
+
return (0, import_row_storage_provider_io.runReportingRowProviderOperation)(context.signal, async () => {
|
|
273
|
+
const blob = blobFor(input);
|
|
274
|
+
const target = pinned(blob, input.nativeVersionRef);
|
|
275
|
+
if (target === null) return "absent";
|
|
276
|
+
const signal = context.signal;
|
|
277
|
+
try {
|
|
278
|
+
const recorded = await target.blob.getProperties({ abortSignal: signal });
|
|
279
|
+
if (recorded.versionId !== target.versionId) return "absent";
|
|
280
|
+
} catch (error) {
|
|
281
|
+
if (isMissing(error) || statusOf(error) === 400) return "absent";
|
|
282
|
+
throw error;
|
|
283
|
+
}
|
|
284
|
+
let deletedCurrent = false;
|
|
285
|
+
try {
|
|
286
|
+
const current = await blob.getProperties({ abortSignal: signal });
|
|
287
|
+
if (current.versionId === target.versionId && current.etag) {
|
|
288
|
+
await blob.delete({ conditions: { ifMatch: current.etag }, abortSignal: signal });
|
|
289
|
+
deletedCurrent = true;
|
|
290
|
+
}
|
|
291
|
+
} catch (error) {
|
|
292
|
+
if (!isMissing(error)) throw error;
|
|
293
|
+
}
|
|
294
|
+
try {
|
|
295
|
+
await target.blob.delete({ abortSignal: signal });
|
|
296
|
+
return "deleted";
|
|
297
|
+
} catch (error) {
|
|
298
|
+
if (isMissing(error) || statusOf(error) === 400) return deletedCurrent ? "deleted" : "absent";
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
306
|
+
0 && (module.exports = {
|
|
307
|
+
createAzureBlobReportingRowObjectProviderV1
|
|
308
|
+
});
|