@productcraft/flags 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/README.md +16 -13
- package/api.md +572 -4
- package/dist/browser/{chunk-OOX7EUCT.js → chunk-OUAC4WID.js} +584 -8
- package/dist/browser/chunk-OUAC4WID.js.map +1 -0
- package/dist/{chunk-RJIVAOBG.cjs → browser/chunk-UYL3NMDA.cjs} +584 -8
- package/dist/browser/chunk-UYL3NMDA.cjs.map +1 -0
- package/dist/browser/index.cjs +4 -4
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/management.cjs +2 -2
- package/dist/browser/management.js +1 -1
- package/dist/browser/testing.cjs +845 -0
- package/dist/browser/testing.cjs.map +1 -1
- package/dist/browser/testing.js +845 -0
- package/dist/browser/testing.js.map +1 -1
- package/dist/{browser/chunk-XZK57G7L.cjs → chunk-5SDZWOUP.cjs} +584 -8
- package/dist/chunk-5SDZWOUP.cjs.map +1 -0
- package/dist/{chunk-CGVDMKEE.js → chunk-7BOM23MI.js} +3 -3
- package/dist/{chunk-CGVDMKEE.js.map → chunk-7BOM23MI.js.map} +1 -1
- package/dist/{chunk-XNJ5OX4X.js → chunk-JGSMXA3G.js} +584 -8
- package/dist/chunk-JGSMXA3G.js.map +1 -0
- package/dist/{chunk-L3AOANTB.cjs → chunk-SHMDNO4G.cjs} +3 -3
- package/dist/{chunk-L3AOANTB.cjs.map → chunk-SHMDNO4G.cjs.map} +1 -1
- package/dist/{client-BWi7PASW.d.cts → client-DVKdRqhR.d.cts} +7751 -3218
- package/dist/{client-BWi7PASW.d.ts → client-DVKdRqhR.d.ts} +7751 -3218
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/management.cjs +2 -2
- package/dist/management.d.cts +1 -1
- package/dist/management.d.ts +1 -1
- package/dist/management.js +1 -1
- package/dist/testing.cjs +848 -3
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +2 -2
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +846 -1
- package/dist/testing.js.map +1 -1
- package/manifest.json +316 -1
- package/package.json +1 -1
- package/dist/browser/chunk-OOX7EUCT.js.map +0 -1
- package/dist/browser/chunk-XZK57G7L.cjs.map +0 -1
- package/dist/chunk-RJIVAOBG.cjs.map +0 -1
- package/dist/chunk-XNJ5OX4X.js.map +0 -1
|
@@ -19,6 +19,202 @@ var APIResource = class {
|
|
|
19
19
|
this._b = bound;
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
+
var ChangeRequestsResource = class extends APIResource {
|
|
23
|
+
/**
|
|
24
|
+
* Apply a change request
|
|
25
|
+
*
|
|
26
|
+
* Writes an approved request through the normal value-write path, only if the value is still at `base_version` (else 409 `CHANGE_REQUEST_STALE`: rebase it). A `ramp` request starts its ramp. Anyone allowed to make the write can apply, including the author's API key or agent: the approval is what the policy asks for.
|
|
27
|
+
*
|
|
28
|
+
* @param changeRequestId - Id of the change request.
|
|
29
|
+
* @param options - Per-request options.
|
|
30
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
31
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
32
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
33
|
+
* @throws {ConflictError} 409 CONFLICT, CHANGE_REQUEST_NOT_OPEN, CHANGE_REQUEST_NOT_APPROVED, CHANGE_REQUEST_STALE, RAMP_ALREADY_ACTIVE: `CHANGE_REQUEST_NOT_OPEN` (its `status` does not allow this; `details.status`), `CHANGE_REQUEST_NOT_APPROVED` (it still needs approvals) or `CHANGE_REQUEST_STALE` (the value changed since it was proposed: rebase it). `RAMP_ALREADY_ACTIVE`: a ramp already runs on the flag.
|
|
34
|
+
* @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_VALUE, INVALID_TARGETING, SEGMENT_NOT_FOUND, CONFIDENTIAL_LIST_NOT_EDITABLE, PERCENTAGES_MUST_SUM_TO_100, PREREQUISITE_NOT_FOUND, PREREQUISITE_TYPE_MISMATCH, CIRCULAR_PREREQUISITE, LIMIT_EXCEEDED, NOTE_REQUIRED, NOTHING_TO_PROPOSE, RAMP_INVALID, RUN_AT_INVALID: The proposal is refused by the checks the write itself makes: `INVALID_VALUE`, `INVALID_TARGETING`, `SEGMENT_NOT_FOUND`, `CONFIDENTIAL_LIST_NOT_EDITABLE`, `PERCENTAGES_MUST_SUM_TO_100`, `PREREQUISITE_NOT_FOUND`, `PREREQUISITE_TYPE_MISMATCH`, `CIRCULAR_PREREQUISITE`, `LIMIT_EXCEEDED`, `NOTE_REQUIRED`, `NOTHING_TO_PROPOSE` (it equals what the environment serves now), `RAMP_INVALID` or `RUN_AT_INVALID`.
|
|
35
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
36
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
37
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/apply
|
|
38
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-apply
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const changeRequest = await flags.changeRequests.apply("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
apply(changeRequestId, options) {
|
|
45
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/apply", pathParams: { change_request_id: changeRequestId } }, options);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Approve a change request
|
|
49
|
+
*
|
|
50
|
+
* Records your approval. With `required_approvals` approvals from different reviewers the request is `approved`; `apply: true` then applies it at once. Only a person signed in to the console who is not the author (nor the person an agent proposed it for) can approve, and they must be allowed to make the write. A stale request (the value moved) cannot be approved: rebase it.
|
|
51
|
+
*
|
|
52
|
+
* @param changeRequestId - Id of the change request.
|
|
53
|
+
* @param params - `Flags.ChangeRequestApproveParams`.
|
|
54
|
+
* @param options - Per-request options.
|
|
55
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
56
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED, REVIEWER_MUST_BE_HUMAN, SELF_APPROVAL_NOT_ALLOWED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment. `REVIEWER_MUST_BE_HUMAN`: only a person signed in to the console can review (never an API key or an AI agent). `SELF_APPROVAL_NOT_ALLOWED`: the author, or the person an agent proposed it for, cannot review it.
|
|
57
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
58
|
+
* @throws {ConflictError} 409 CONFLICT, CHANGE_REQUEST_NOT_OPEN, CHANGE_REQUEST_NOT_APPROVED, CHANGE_REQUEST_STALE, ALREADY_REVIEWED: `CHANGE_REQUEST_NOT_OPEN` (its `status` does not allow this; `details.status`), `CHANGE_REQUEST_NOT_APPROVED` (it still needs approvals) or `CHANGE_REQUEST_STALE` (the value changed since it was proposed: rebase it). `ALREADY_REVIEWED`: you already reviewed it.
|
|
59
|
+
* @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_VALUE, INVALID_TARGETING, SEGMENT_NOT_FOUND, CONFIDENTIAL_LIST_NOT_EDITABLE, PERCENTAGES_MUST_SUM_TO_100, PREREQUISITE_NOT_FOUND, PREREQUISITE_TYPE_MISMATCH, CIRCULAR_PREREQUISITE, LIMIT_EXCEEDED, NOTE_REQUIRED, NOTHING_TO_PROPOSE, RAMP_INVALID, RUN_AT_INVALID: The proposal is refused by the checks the write itself makes: `INVALID_VALUE`, `INVALID_TARGETING`, `SEGMENT_NOT_FOUND`, `CONFIDENTIAL_LIST_NOT_EDITABLE`, `PERCENTAGES_MUST_SUM_TO_100`, `PREREQUISITE_NOT_FOUND`, `PREREQUISITE_TYPE_MISMATCH`, `CIRCULAR_PREREQUISITE`, `LIMIT_EXCEEDED`, `NOTE_REQUIRED`, `NOTHING_TO_PROPOSE` (it equals what the environment serves now), `RAMP_INVALID` or `RUN_AT_INVALID`.
|
|
60
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
61
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
62
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/approve
|
|
63
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-approve
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* const changeRequest = await flags.changeRequests.approve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { apply: true });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
approve(changeRequestId, params, options) {
|
|
70
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/approve", pathParams: { change_request_id: changeRequestId }, body: params }, options);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Cancel a change request
|
|
74
|
+
*
|
|
75
|
+
* Withdraws an open request (and its schedule). The author can always cancel; anyone else needs the right to make the write.
|
|
76
|
+
*
|
|
77
|
+
* @param changeRequestId - Id of the change request.
|
|
78
|
+
* @param params - `Flags.ChangeRequestCancelParams`.
|
|
79
|
+
* @param options - Per-request options.
|
|
80
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
81
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
82
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
83
|
+
* @throws {ConflictError} 409 CONFLICT, CHANGE_REQUEST_NOT_OPEN, CHANGE_REQUEST_NOT_APPROVED, CHANGE_REQUEST_STALE: `CHANGE_REQUEST_NOT_OPEN` (its `status` does not allow this; `details.status`), `CHANGE_REQUEST_NOT_APPROVED` (it still needs approvals) or `CHANGE_REQUEST_STALE` (the value changed since it was proposed: rebase it).
|
|
84
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
85
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
86
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/cancel
|
|
87
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-cancel
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const changeRequest = await flags.changeRequests.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
cancel(changeRequestId, params, options) {
|
|
94
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/cancel", pathParams: { change_request_id: changeRequestId }, body: params }, options);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* List change requests
|
|
98
|
+
*
|
|
99
|
+
* The workspace's change requests, newest first. `status=open` is the review queue (pending, approved, scheduled and failed requests).
|
|
100
|
+
*
|
|
101
|
+
* @param params - `Flags.ChangeRequestListParams`.
|
|
102
|
+
* @param options - Per-request options.
|
|
103
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad filter, cursor or `limit`.
|
|
104
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
105
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
106
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
107
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
108
|
+
* @see GET /v1/workspaces/{workspace_id}/change-requests
|
|
109
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-change-requests
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* for await (const changeRequest of flags.changeRequests.list()) {
|
|
113
|
+
* console.log(changeRequest);
|
|
114
|
+
* }
|
|
115
|
+
* const page = await flags.changeRequests.list({}, { timeout: 5_000 });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
list(params, options) {
|
|
119
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/change-requests", query: params }, options);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Rebase a change request
|
|
123
|
+
*
|
|
124
|
+
* Re-diffs a stale request against the current value: the proposed targeting stays, `before` and `base_version` become the current ones, its approvals are cleared and it is `pending` again (reviewers approve the new diff).
|
|
125
|
+
*
|
|
126
|
+
* @param changeRequestId - Id of the change request.
|
|
127
|
+
* @param options - Per-request options.
|
|
128
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
129
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
130
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
131
|
+
* @throws {ConflictError} 409 CONFLICT, CHANGE_REQUEST_NOT_OPEN, CHANGE_REQUEST_NOT_APPROVED, CHANGE_REQUEST_STALE: `CHANGE_REQUEST_NOT_OPEN` (its `status` does not allow this; `details.status`), `CHANGE_REQUEST_NOT_APPROVED` (it still needs approvals) or `CHANGE_REQUEST_STALE` (the value changed since it was proposed: rebase it).
|
|
132
|
+
* @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_VALUE, INVALID_TARGETING, SEGMENT_NOT_FOUND, CONFIDENTIAL_LIST_NOT_EDITABLE, PERCENTAGES_MUST_SUM_TO_100, PREREQUISITE_NOT_FOUND, PREREQUISITE_TYPE_MISMATCH, CIRCULAR_PREREQUISITE, LIMIT_EXCEEDED, NOTE_REQUIRED, NOTHING_TO_PROPOSE, RAMP_INVALID, RUN_AT_INVALID: The proposal is refused by the checks the write itself makes: `INVALID_VALUE`, `INVALID_TARGETING`, `SEGMENT_NOT_FOUND`, `CONFIDENTIAL_LIST_NOT_EDITABLE`, `PERCENTAGES_MUST_SUM_TO_100`, `PREREQUISITE_NOT_FOUND`, `PREREQUISITE_TYPE_MISMATCH`, `CIRCULAR_PREREQUISITE`, `LIMIT_EXCEEDED`, `NOTE_REQUIRED`, `NOTHING_TO_PROPOSE` (it equals what the environment serves now), `RAMP_INVALID` or `RUN_AT_INVALID`.
|
|
133
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
134
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
135
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/rebase
|
|
136
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-rebase
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const changeRequest = await flags.changeRequests.rebase("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
rebase(changeRequestId, options) {
|
|
143
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/rebase", pathParams: { change_request_id: changeRequestId } }, options);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Reject a change request
|
|
147
|
+
*
|
|
148
|
+
* Rejects the request (final); the author is emailed with your note. Same reviewer rules as approve.
|
|
149
|
+
*
|
|
150
|
+
* @param changeRequestId - Id of the change request.
|
|
151
|
+
* @param params - `Flags.ChangeRequestRejectParams`.
|
|
152
|
+
* @param options - Per-request options.
|
|
153
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `apply` is only for approvals.
|
|
154
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
155
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED, REVIEWER_MUST_BE_HUMAN, SELF_APPROVAL_NOT_ALLOWED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment. `REVIEWER_MUST_BE_HUMAN`: only a person signed in to the console can review (never an API key or an AI agent). `SELF_APPROVAL_NOT_ALLOWED`: the author, or the person an agent proposed it for, cannot review it.
|
|
156
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
157
|
+
* @throws {ConflictError} 409 CONFLICT, CHANGE_REQUEST_NOT_OPEN, CHANGE_REQUEST_NOT_APPROVED, CHANGE_REQUEST_STALE, ALREADY_REVIEWED: `CHANGE_REQUEST_NOT_OPEN` (its `status` does not allow this; `details.status`), `CHANGE_REQUEST_NOT_APPROVED` (it still needs approvals) or `CHANGE_REQUEST_STALE` (the value changed since it was proposed: rebase it). `ALREADY_REVIEWED`: you already reviewed it.
|
|
158
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
159
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
160
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/reject
|
|
161
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-reject
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const changeRequest = await flags.changeRequests.reject("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { apply: true });
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
reject(changeRequestId, params, options) {
|
|
168
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/reject", pathParams: { change_request_id: changeRequestId }, body: params }, options);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get a change request
|
|
172
|
+
*
|
|
173
|
+
* One change request with its diff, reviews and whether it is `stale`.
|
|
174
|
+
*
|
|
175
|
+
* @param changeRequestId - Id of the change request.
|
|
176
|
+
* @param options - Per-request options.
|
|
177
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
178
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
179
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
180
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
181
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
182
|
+
* @see GET /v1/workspaces/{workspace_id}/change-requests/{change_request_id}
|
|
183
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-change-requests-change-request-id
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const changeRequest = await flags.changeRequests.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
retrieve(changeRequestId, options) {
|
|
190
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}", pathParams: { change_request_id: changeRequestId } }, options);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Schedule a change request
|
|
194
|
+
*
|
|
195
|
+
* Applies an approved `value` request at `run_at` (status `scheduled`). If the value moved by then the request becomes `failed`: rebase it. Cancel the schedule by cancelling the scheduled change or the request.
|
|
196
|
+
*
|
|
197
|
+
* @param changeRequestId - Id of the change request.
|
|
198
|
+
* @param params - `Flags.ChangeRequestScheduleParams`.
|
|
199
|
+
* @param options - Per-request options.
|
|
200
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
201
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
202
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
203
|
+
* @throws {ConflictError} 409 CONFLICT, CHANGE_REQUEST_NOT_OPEN, CHANGE_REQUEST_NOT_APPROVED, CHANGE_REQUEST_STALE: `CHANGE_REQUEST_NOT_OPEN` (its `status` does not allow this; `details.status`), `CHANGE_REQUEST_NOT_APPROVED` (it still needs approvals) or `CHANGE_REQUEST_STALE` (the value changed since it was proposed: rebase it).
|
|
204
|
+
* @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, RUN_AT_INVALID: `RUN_AT_INVALID`: `run_at` is in the past or more than a year ahead, or the request is a ramp (it carries its own times).
|
|
205
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
206
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
207
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/schedule
|
|
208
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-schedule
|
|
209
|
+
* @example
|
|
210
|
+
* ```ts
|
|
211
|
+
* const changeRequest = await flags.changeRequests.schedule("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { run_at: "2026-11-20T09:00:00.000Z" });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
schedule(changeRequestId, params, options) {
|
|
215
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/schedule", pathParams: { change_request_id: changeRequestId }, body: params }, options);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
22
218
|
var ChangesResource = class extends APIResource {
|
|
23
219
|
/**
|
|
24
220
|
* Get a change
|
|
@@ -744,7 +940,7 @@ var ProjectsEnvironmentsResource = class extends APIResource {
|
|
|
744
940
|
/**
|
|
745
941
|
* Update an environment
|
|
746
942
|
*
|
|
747
|
-
* Name, color, order, `protected` and `
|
|
943
|
+
* Name, color, order, `protected`, `require_note`, and the approval policy (`approval_policy`, `required_approvals`); the key never changes. Changing a guard is recorded in the workspace audit log. Needs `flags.project.manage`; only a person signed in to the console can change the approval policy.
|
|
748
944
|
*
|
|
749
945
|
* @param projectId - Id of the project.
|
|
750
946
|
* @param environmentId - Id of the environment.
|
|
@@ -752,7 +948,7 @@ var ProjectsEnvironmentsResource = class extends APIResource {
|
|
|
752
948
|
* @param options - Per-request options.
|
|
753
949
|
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is invalid.
|
|
754
950
|
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
755
|
-
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
951
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED, APPROVAL_POLICY_HUMAN_ONLY: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). `APPROVAL_POLICY_HUMAN_ONLY`: an API key or an agent tried to change `approval_policy` or `required_approvals`.
|
|
756
952
|
* @throws {NotFoundError} 404 NOT_FOUND, ENVIRONMENT_NOT_FOUND: `ENVIRONMENT_NOT_FOUND`: no such environment in this project.
|
|
757
953
|
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
758
954
|
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
@@ -760,7 +956,7 @@ var ProjectsEnvironmentsResource = class extends APIResource {
|
|
|
760
956
|
* @see https://productcraft.co/docs/flags/api-reference#patch-v1-workspaces-workspace-id-projects-project-id-environments-environment-id
|
|
761
957
|
* @example
|
|
762
958
|
* ```ts
|
|
763
|
-
* const environment = await flags.projects.environments.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", {
|
|
959
|
+
* const environment = await flags.projects.environments.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { approval_policy: "off" });
|
|
764
960
|
* ```
|
|
765
961
|
*/
|
|
766
962
|
update(projectId, environmentId, params, options) {
|
|
@@ -829,11 +1025,63 @@ var ProjectsSegmentsResource = class extends APIResource {
|
|
|
829
1025
|
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/projects/{project_id}/segments", pathParams: { project_id: projectId }, query: params }, options);
|
|
830
1026
|
}
|
|
831
1027
|
};
|
|
1028
|
+
var ProjectsStaleFlagsResource = class extends APIResource {
|
|
1029
|
+
/**
|
|
1030
|
+
* List stale flags
|
|
1031
|
+
*
|
|
1032
|
+
* Flags that are probably dead code, longest unchanged first, each with its `reasons`: no value or targeting change in `days` (default the project's `stale_after_days`), serving one value to everyone in every environment (`rolled_out`, `turned_off`, `same_value_everywhere`), or marked `released` / `deprecated`. `suggested_value` is the literal to replace the flag read with when cleaning it up; `prerequisite_of` counts settings that still depend on it. Permanent flags are never listed. Flags collects no evaluation data, so the report cannot tell whether code still reads a flag (`evaluation_data: not_collected`).
|
|
1033
|
+
*
|
|
1034
|
+
* @param projectId - Id of the project.
|
|
1035
|
+
* @param params - `Flags.ProjectStaleFlagListParams`.
|
|
1036
|
+
* @param options - Per-request options.
|
|
1037
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad `days`, `reason`, cursor or `limit`.
|
|
1038
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1039
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
1040
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PROJECT_NOT_FOUND: `PROJECT_NOT_FOUND`: no such project in this workspace.
|
|
1041
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1042
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1043
|
+
* @see GET /v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags
|
|
1044
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-projects-project-id-stale-flags
|
|
1045
|
+
* @example
|
|
1046
|
+
* ```ts
|
|
1047
|
+
* for await (const staleFlag of flags.projects.staleFlags.list("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f")) {
|
|
1048
|
+
* console.log(staleFlag);
|
|
1049
|
+
* }
|
|
1050
|
+
* const page = await flags.projects.staleFlags.list("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", {}, { timeout: 5_000 });
|
|
1051
|
+
* ```
|
|
1052
|
+
*/
|
|
1053
|
+
list(projectId, params, options) {
|
|
1054
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags", pathParams: { project_id: projectId }, query: params }, options);
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* Send the stale-flag digest now
|
|
1058
|
+
*
|
|
1059
|
+
* Emails the digest that otherwise goes out every Monday at 07:00 UTC: each flag owner gets their stale flags; flags without an owner go to the workspace owners. Recipients are always members of the workspace.
|
|
1060
|
+
*
|
|
1061
|
+
* @param projectId - Id of the project.
|
|
1062
|
+
* @param options - Per-request options.
|
|
1063
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1064
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
1065
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PROJECT_NOT_FOUND: `PROJECT_NOT_FOUND`: no such project in this workspace.
|
|
1066
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1067
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1068
|
+
* @see POST /v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags/digest
|
|
1069
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-projects-project-id-stale-flags-digest
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```ts
|
|
1072
|
+
* const staleDigest = await flags.projects.staleFlags.sendDigest("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
1073
|
+
* ```
|
|
1074
|
+
*/
|
|
1075
|
+
sendDigest(projectId, options) {
|
|
1076
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags/digest", pathParams: { project_id: projectId } }, options);
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
832
1079
|
var ProjectsResource = class extends APIResource {
|
|
833
1080
|
#changes;
|
|
834
1081
|
#configs;
|
|
835
1082
|
#environments;
|
|
836
1083
|
#segments;
|
|
1084
|
+
#staleFlags;
|
|
837
1085
|
get changes() {
|
|
838
1086
|
return this.#changes ??= new ProjectsChangesResource(this._client, this._b);
|
|
839
1087
|
}
|
|
@@ -846,6 +1094,9 @@ var ProjectsResource = class extends APIResource {
|
|
|
846
1094
|
get segments() {
|
|
847
1095
|
return this.#segments ??= new ProjectsSegmentsResource(this._client, this._b);
|
|
848
1096
|
}
|
|
1097
|
+
get staleFlags() {
|
|
1098
|
+
return this.#staleFlags ??= new ProjectsStaleFlagsResource(this._client, this._b);
|
|
1099
|
+
}
|
|
849
1100
|
/**
|
|
850
1101
|
* Create a project
|
|
851
1102
|
*
|
|
@@ -967,6 +1218,200 @@ var ProjectsResource = class extends APIResource {
|
|
|
967
1218
|
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/projects/{project_id}", pathParams: { project_id: projectId }, body: params }, options);
|
|
968
1219
|
}
|
|
969
1220
|
};
|
|
1221
|
+
var RampsResource = class extends APIResource {
|
|
1222
|
+
/**
|
|
1223
|
+
* Cancel a ramp
|
|
1224
|
+
*
|
|
1225
|
+
* Stops the ramp where it is: the split it reached stays. Change or restore the value to undo it.
|
|
1226
|
+
*
|
|
1227
|
+
* @param rampId - Id of the ramp.
|
|
1228
|
+
* @param params - `Flags.RampCancelParams`.
|
|
1229
|
+
* @param options - Per-request options.
|
|
1230
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1231
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
1232
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1233
|
+
* @throws {ConflictError} 409 CONFLICT, RAMP_NOT_LIVE: `RAMP_NOT_LIVE`: the ramp already completed, failed or was cancelled.
|
|
1234
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1235
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1236
|
+
* @see POST /v1/workspaces/{workspace_id}/ramps/{ramp_id}/cancel
|
|
1237
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-ramps-ramp-id-cancel
|
|
1238
|
+
* @example
|
|
1239
|
+
* ```ts
|
|
1240
|
+
* const ramp = await flags.ramps.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1241
|
+
* ```
|
|
1242
|
+
*/
|
|
1243
|
+
cancel(rampId, params, options) {
|
|
1244
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}/cancel", pathParams: { ramp_id: rampId }, body: params }, options);
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* List ramps
|
|
1248
|
+
*
|
|
1249
|
+
* Percentage ramps, newest first. Filter by `status` (`active`, `paused`, `completed`, `cancelled`, `failed`), project, environment or setting.
|
|
1250
|
+
*
|
|
1251
|
+
* @param params - `Flags.RampListParams`.
|
|
1252
|
+
* @param options - Per-request options.
|
|
1253
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad filter, cursor or `limit`.
|
|
1254
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1255
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
1256
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1257
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1258
|
+
* @see GET /v1/workspaces/{workspace_id}/ramps
|
|
1259
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-ramps
|
|
1260
|
+
* @example
|
|
1261
|
+
* ```ts
|
|
1262
|
+
* for await (const ramp of flags.ramps.list()) {
|
|
1263
|
+
* console.log(ramp);
|
|
1264
|
+
* }
|
|
1265
|
+
* const page = await flags.ramps.list({}, { timeout: 5_000 });
|
|
1266
|
+
* ```
|
|
1267
|
+
*/
|
|
1268
|
+
list(params, options) {
|
|
1269
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/ramps", query: params }, options);
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* Pause a ramp
|
|
1273
|
+
*
|
|
1274
|
+
* Holds the ramp at its current percentage; no further steps apply until it is resumed. Allowed even where changes need approval (it is a safety stop).
|
|
1275
|
+
*
|
|
1276
|
+
* @param rampId - Id of the ramp.
|
|
1277
|
+
* @param params - `Flags.RampPauseParams`.
|
|
1278
|
+
* @param options - Per-request options.
|
|
1279
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1280
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
1281
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1282
|
+
* @throws {ConflictError} 409 CONFLICT, RAMP_NOT_LIVE: `RAMP_NOT_LIVE`: the ramp is not active.
|
|
1283
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1284
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1285
|
+
* @see POST /v1/workspaces/{workspace_id}/ramps/{ramp_id}/pause
|
|
1286
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-ramps-ramp-id-pause
|
|
1287
|
+
* @example
|
|
1288
|
+
* ```ts
|
|
1289
|
+
* const ramp = await flags.ramps.pause("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1290
|
+
* ```
|
|
1291
|
+
*/
|
|
1292
|
+
pause(rampId, params, options) {
|
|
1293
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}/pause", pathParams: { ramp_id: rampId }, body: params }, options);
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Resume a ramp
|
|
1297
|
+
*
|
|
1298
|
+
* Continues a paused ramp. Steps whose time passed while it was paused are not replayed one by one: the latest due step applies on the next tick.
|
|
1299
|
+
*
|
|
1300
|
+
* @param rampId - Id of the ramp.
|
|
1301
|
+
* @param params - `Flags.RampResumeParams`.
|
|
1302
|
+
* @param options - Per-request options.
|
|
1303
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1304
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
1305
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1306
|
+
* @throws {ConflictError} 409 CONFLICT, RAMP_NOT_LIVE: `RAMP_NOT_LIVE`: the ramp is not paused.
|
|
1307
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1308
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1309
|
+
* @see POST /v1/workspaces/{workspace_id}/ramps/{ramp_id}/resume
|
|
1310
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-ramps-ramp-id-resume
|
|
1311
|
+
* @example
|
|
1312
|
+
* ```ts
|
|
1313
|
+
* const ramp = await flags.ramps.resume("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1314
|
+
* ```
|
|
1315
|
+
*/
|
|
1316
|
+
resume(rampId, params, options) {
|
|
1317
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}/resume", pathParams: { ramp_id: rampId }, body: params }, options);
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Get a ramp
|
|
1321
|
+
*
|
|
1322
|
+
* One ramp with its steps, the percentage it reached and its state.
|
|
1323
|
+
*
|
|
1324
|
+
* @param rampId - Id of the ramp.
|
|
1325
|
+
* @param options - Per-request options.
|
|
1326
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1327
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
1328
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1329
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1330
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1331
|
+
* @see GET /v1/workspaces/{workspace_id}/ramps/{ramp_id}
|
|
1332
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-ramps-ramp-id
|
|
1333
|
+
* @example
|
|
1334
|
+
* ```ts
|
|
1335
|
+
* const ramp = await flags.ramps.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
1336
|
+
* ```
|
|
1337
|
+
*/
|
|
1338
|
+
retrieve(rampId, options) {
|
|
1339
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}", pathParams: { ramp_id: rampId } }, options);
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
var ScheduledChangesResource = class extends APIResource {
|
|
1343
|
+
/**
|
|
1344
|
+
* Cancel a scheduled change
|
|
1345
|
+
*
|
|
1346
|
+
* Cancels a pending scheduled change. A scheduled change request goes back to `approved`.
|
|
1347
|
+
*
|
|
1348
|
+
* @param scheduledChangeId - Id of the scheduled change.
|
|
1349
|
+
* @param params - `Flags.ScheduledChangeCancelParams`.
|
|
1350
|
+
* @param options - Per-request options.
|
|
1351
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1352
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
1353
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SCHEDULED_CHANGE_NOT_FOUND: `SCHEDULED_CHANGE_NOT_FOUND`: no such scheduled change in this workspace.
|
|
1354
|
+
* @throws {ConflictError} 409 CONFLICT, SCHEDULED_CHANGE_NOT_PENDING: `SCHEDULED_CHANGE_NOT_PENDING`: it already ran or was cancelled.
|
|
1355
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1356
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1357
|
+
* @see POST /v1/workspaces/{workspace_id}/scheduled-changes/{scheduled_change_id}/cancel
|
|
1358
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-scheduled-changes-scheduled-change-id-cancel
|
|
1359
|
+
* @example
|
|
1360
|
+
* ```ts
|
|
1361
|
+
* const scheduledChange = await flags.scheduledChanges.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1362
|
+
* ```
|
|
1363
|
+
*/
|
|
1364
|
+
cancel(scheduledChangeId, params, options) {
|
|
1365
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/scheduled-changes/{scheduled_change_id}/cancel", pathParams: { scheduled_change_id: scheduledChangeId }, body: params }, options);
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* List scheduled changes
|
|
1369
|
+
*
|
|
1370
|
+
* Scheduled value changes, soonest first. Filter by `status` (`pending`, `applied`, `failed`, `cancelled`), project, environment or setting.
|
|
1371
|
+
*
|
|
1372
|
+
* @param params - `Flags.ScheduledChangeListParams`.
|
|
1373
|
+
* @param options - Per-request options.
|
|
1374
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad filter, cursor or `limit`.
|
|
1375
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1376
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
1377
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1378
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1379
|
+
* @see GET /v1/workspaces/{workspace_id}/scheduled-changes
|
|
1380
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-scheduled-changes
|
|
1381
|
+
* @example
|
|
1382
|
+
* ```ts
|
|
1383
|
+
* for await (const scheduledChange of flags.scheduledChanges.list()) {
|
|
1384
|
+
* console.log(scheduledChange);
|
|
1385
|
+
* }
|
|
1386
|
+
* const page = await flags.scheduledChanges.list({}, { timeout: 5_000 });
|
|
1387
|
+
* ```
|
|
1388
|
+
*/
|
|
1389
|
+
list(params, options) {
|
|
1390
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/scheduled-changes", query: params }, options);
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Get a scheduled change
|
|
1394
|
+
*
|
|
1395
|
+
* One scheduled change, with what it will write and, once run, the history entry or the error.
|
|
1396
|
+
*
|
|
1397
|
+
* @param scheduledChangeId - Id of the scheduled change.
|
|
1398
|
+
* @param options - Per-request options.
|
|
1399
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1400
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`).
|
|
1401
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SCHEDULED_CHANGE_NOT_FOUND: `SCHEDULED_CHANGE_NOT_FOUND`: no such scheduled change in this workspace.
|
|
1402
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1403
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1404
|
+
* @see GET /v1/workspaces/{workspace_id}/scheduled-changes/{scheduled_change_id}
|
|
1405
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-scheduled-changes-scheduled-change-id
|
|
1406
|
+
* @example
|
|
1407
|
+
* ```ts
|
|
1408
|
+
* const scheduledChange = await flags.scheduledChanges.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
1409
|
+
* ```
|
|
1410
|
+
*/
|
|
1411
|
+
retrieve(scheduledChangeId, options) {
|
|
1412
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/scheduled-changes/{scheduled_change_id}", pathParams: { scheduled_change_id: scheduledChangeId } }, options);
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
970
1415
|
var SegmentsResource = class extends APIResource {
|
|
971
1416
|
/**
|
|
972
1417
|
* Delete a segment
|
|
@@ -1064,7 +1509,106 @@ var SegmentsResource = class extends APIResource {
|
|
|
1064
1509
|
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/segments/{segment_id}", pathParams: { segment_id: segmentId }, body: params }, options);
|
|
1065
1510
|
}
|
|
1066
1511
|
};
|
|
1512
|
+
var SettingsValuesChangeRequestsResource = class extends APIResource {
|
|
1513
|
+
/**
|
|
1514
|
+
* Propose a change
|
|
1515
|
+
*
|
|
1516
|
+
* Proposes a value write (`replace` or `patch`, as PUT / PATCH …/values take them) or a timed ramp (`ramp`) for review instead of making it. The proposal is validated as the write would be and stored without any confidential cleartext; the environment's owners and admins are emailed and `change_request.created` is sent to webhooks. Works in any environment; where the environment's `approval_policy` applies to the caller it is the only way to change a value. Send the `version` you read.
|
|
1517
|
+
*
|
|
1518
|
+
* @param settingId - Id of the setting.
|
|
1519
|
+
* @param environmentId - Id of an environment of the same project.
|
|
1520
|
+
* @param params - `Flags.SettingsValueChangeRequestCreateParams`.
|
|
1521
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1522
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field does not fit the `operation`, or is missing.
|
|
1523
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1524
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
1525
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SETTING_NOT_FOUND, ENVIRONMENT_NOT_FOUND: `SETTING_NOT_FOUND` or `ENVIRONMENT_NOT_FOUND`.
|
|
1526
|
+
* @throws {ConflictError} 409 CONFLICT, VERSION_CONFLICT, RAMP_ALREADY_ACTIVE, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `VERSION_CONFLICT`: the value changed since you read it. `RAMP_ALREADY_ACTIVE`: the flag already has a ramp in this environment. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
1527
|
+
* @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_VALUE, INVALID_TARGETING, SEGMENT_NOT_FOUND, CONFIDENTIAL_LIST_NOT_EDITABLE, PERCENTAGES_MUST_SUM_TO_100, PREREQUISITE_NOT_FOUND, PREREQUISITE_TYPE_MISMATCH, CIRCULAR_PREREQUISITE, LIMIT_EXCEEDED, NOTE_REQUIRED, NOTHING_TO_PROPOSE, RAMP_INVALID, RUN_AT_INVALID: The proposal is refused by the checks the write itself makes: `INVALID_VALUE`, `INVALID_TARGETING`, `SEGMENT_NOT_FOUND`, `CONFIDENTIAL_LIST_NOT_EDITABLE`, `PERCENTAGES_MUST_SUM_TO_100`, `PREREQUISITE_NOT_FOUND`, `PREREQUISITE_TYPE_MISMATCH`, `CIRCULAR_PREREQUISITE`, `LIMIT_EXCEEDED`, `NOTE_REQUIRED`, `NOTHING_TO_PROPOSE` (it equals what the environment serves now), `RAMP_INVALID` or `RUN_AT_INVALID`.
|
|
1528
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1529
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1530
|
+
* @see POST /v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/change-requests
|
|
1531
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-settings-setting-id-values-environment-id-change-requests
|
|
1532
|
+
* @example
|
|
1533
|
+
* ```ts
|
|
1534
|
+
* const changeRequest = await flags.settings.values.changeRequests.create("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { operation: "patch", version: 7 });
|
|
1535
|
+
* ```
|
|
1536
|
+
*/
|
|
1537
|
+
create(settingId, environmentId, params, options) {
|
|
1538
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/change-requests", pathParams: { setting_id: settingId, environment_id: environmentId }, body: params, idempotent: true }, options);
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
var SettingsValuesRampsResource = class extends APIResource {
|
|
1542
|
+
/**
|
|
1543
|
+
* Start a ramp
|
|
1544
|
+
*
|
|
1545
|
+
* Rolls `value` out to a growing percentage at set times (for example 5% → 25% → 50% → 100%): each step sets the flag-level split, so users already in keep the value as it grows (sticky bucketing), and a final 100% step makes it the default. Rules still decide first. Where the environment needs approval for the caller this answers 409 `APPROVAL_REQUIRED`: propose it as a change request with `operation: ramp`.
|
|
1546
|
+
*
|
|
1547
|
+
* @param settingId - Id of the setting.
|
|
1548
|
+
* @param environmentId - Id of an environment of the same project.
|
|
1549
|
+
* @param params - `Flags.SettingsValueRampCreateParams`.
|
|
1550
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1551
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is missing or invalid.
|
|
1552
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1553
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
1554
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SETTING_NOT_FOUND, ENVIRONMENT_NOT_FOUND: `SETTING_NOT_FOUND` or `ENVIRONMENT_NOT_FOUND`.
|
|
1555
|
+
* @throws {ConflictError} 409 CONFLICT, APPROVAL_REQUIRED, RAMP_ALREADY_ACTIVE, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `APPROVAL_REQUIRED`: the environment needs approval for this caller. `RAMP_ALREADY_ACTIVE`: the flag already has a live ramp here. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
1556
|
+
* @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, RAMP_INVALID, INVALID_VALUE, NOTE_REQUIRED: `RAMP_INVALID` (`details.errors` lists each step problem, or the value is already the default), `INVALID_VALUE` or `NOTE_REQUIRED`.
|
|
1557
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1558
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1559
|
+
* @see POST /v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/ramps
|
|
1560
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-settings-setting-id-values-environment-id-ramps
|
|
1561
|
+
* @example
|
|
1562
|
+
* ```ts
|
|
1563
|
+
* const ramp = await flags.settings.values.ramps.create("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { steps: [{ at: "2026-11-20T09:00:00.000Z", percentage: 25 }], value: true });
|
|
1564
|
+
* ```
|
|
1565
|
+
*/
|
|
1566
|
+
create(settingId, environmentId, params, options) {
|
|
1567
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/ramps", pathParams: { setting_id: settingId, environment_id: environmentId }, body: params, idempotent: true }, options);
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
var SettingsValuesScheduledChangesResource = class extends APIResource {
|
|
1571
|
+
/**
|
|
1572
|
+
* Schedule a change
|
|
1573
|
+
*
|
|
1574
|
+
* Schedules a value write for `run_at` (to within about 30 seconds): a `patch` (turn a flag on at 09:00) applies to whatever the value is then; a `replace` applies only if the value is still at `version`. Where the environment needs approval for the caller this answers 409 `APPROVAL_REQUIRED`: propose a change request and schedule it once approved.
|
|
1575
|
+
*
|
|
1576
|
+
* @param settingId - Id of the setting.
|
|
1577
|
+
* @param environmentId - Id of an environment of the same project.
|
|
1578
|
+
* @param params - `Flags.SettingsValueScheduledChangeCreateParams`.
|
|
1579
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1580
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field does not fit the `operation`.
|
|
1581
|
+
* @throws {AuthenticationError} 401 UNAUTHORIZED: Missing, expired or invalid bearer token (`UNAUTHORIZED`). Send a workspace API key or a platform session token as `Authorization: Bearer <token>`.
|
|
1582
|
+
* @throws {PermissionDeniedError} 403 FORBIDDEN, SERVICE_NOT_ENABLED: The caller lacks the action this route needs (`message` names it), or the workspace has not enabled Flags (`SERVICE_NOT_ENABLED`). The caller also needs `flags.value.update` on the environment and the setting, plus `flags.protected.update` in a protected environment.
|
|
1583
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SETTING_NOT_FOUND, ENVIRONMENT_NOT_FOUND: `SETTING_NOT_FOUND` or `ENVIRONMENT_NOT_FOUND`.
|
|
1584
|
+
* @throws {ConflictError} 409 CONFLICT, APPROVAL_REQUIRED, VERSION_CONFLICT, IDEMPOTENCY_KEY_REUSE, IDEMPOTENCY_IN_PROGRESS: `APPROVAL_REQUIRED`: the environment needs approval for this caller. `VERSION_CONFLICT`: the value changed since you read it. Idempotency: `IDEMPOTENCY_KEY_REUSE` when this `Idempotency-Key` was already used with a different body or route; `IDEMPOTENCY_IN_PROGRESS` while another request with the same key is still running (retry after `Retry-After` seconds, with the same key).
|
|
1585
|
+
* @throws {UnprocessableEntityError} 422 UNPROCESSABLE_ENTITY, INVALID_VALUE, INVALID_TARGETING, SEGMENT_NOT_FOUND, CONFIDENTIAL_LIST_NOT_EDITABLE, PERCENTAGES_MUST_SUM_TO_100, PREREQUISITE_NOT_FOUND, PREREQUISITE_TYPE_MISMATCH, CIRCULAR_PREREQUISITE, LIMIT_EXCEEDED, NOTE_REQUIRED, NOTHING_TO_PROPOSE, RAMP_INVALID, RUN_AT_INVALID: The proposal is refused by the checks the write itself makes: `INVALID_VALUE`, `INVALID_TARGETING`, `SEGMENT_NOT_FOUND`, `CONFIDENTIAL_LIST_NOT_EDITABLE`, `PERCENTAGES_MUST_SUM_TO_100`, `PREREQUISITE_NOT_FOUND`, `PREREQUISITE_TYPE_MISMATCH`, `CIRCULAR_PREREQUISITE`, `LIMIT_EXCEEDED`, `NOTE_REQUIRED`, `NOTHING_TO_PROPOSE` (it equals what the environment serves now), `RAMP_INVALID` or `RUN_AT_INVALID`.
|
|
1586
|
+
* @throws {RateLimitError} 429 RATE_LIMITED: More than 20 requests per second or 600 per minute from this client IP (`RATE_LIMITED`); wait `Retry-After` seconds.
|
|
1587
|
+
* @throws {InternalServerError} 503 SERVICE_UNAVAILABLE, MANAGEMENT_UNAVAILABLE: The management API is temporarily unavailable (`MANAGEMENT_UNAVAILABLE`), for example while its database is unreachable. Wait `Retry-After` seconds and retry; SDK config delivery keeps serving.
|
|
1588
|
+
* @see POST /v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/scheduled-changes
|
|
1589
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-settings-setting-id-values-environment-id-scheduled-changes
|
|
1590
|
+
* @example
|
|
1591
|
+
* ```ts
|
|
1592
|
+
* const scheduledChange = await flags.settings.values.scheduledChanges.create("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { operation: "patch", run_at: "2026-11-20T09:00:00.000Z" });
|
|
1593
|
+
* ```
|
|
1594
|
+
*/
|
|
1595
|
+
create(settingId, environmentId, params, options) {
|
|
1596
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/scheduled-changes", pathParams: { setting_id: settingId, environment_id: environmentId }, body: params, idempotent: true }, options);
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1067
1599
|
var SettingsValuesResource = class extends APIResource {
|
|
1600
|
+
#changeRequests;
|
|
1601
|
+
#ramps;
|
|
1602
|
+
#scheduledChanges;
|
|
1603
|
+
get changeRequests() {
|
|
1604
|
+
return this.#changeRequests ??= new SettingsValuesChangeRequestsResource(this._client, this._b);
|
|
1605
|
+
}
|
|
1606
|
+
get ramps() {
|
|
1607
|
+
return this.#ramps ??= new SettingsValuesRampsResource(this._client, this._b);
|
|
1608
|
+
}
|
|
1609
|
+
get scheduledChanges() {
|
|
1610
|
+
return this.#scheduledChanges ??= new SettingsValuesScheduledChangesResource(this._client, this._b);
|
|
1611
|
+
}
|
|
1068
1612
|
/**
|
|
1069
1613
|
* Replace a value
|
|
1070
1614
|
*
|
|
@@ -1570,15 +2114,21 @@ var WebhooksResource = class extends APIResource {
|
|
|
1570
2114
|
}
|
|
1571
2115
|
};
|
|
1572
2116
|
var FlagsResources = class extends APIResource {
|
|
2117
|
+
#changeRequests;
|
|
1573
2118
|
#changes;
|
|
1574
2119
|
#configs;
|
|
1575
2120
|
#imports;
|
|
1576
2121
|
#limits;
|
|
1577
2122
|
#projects;
|
|
2123
|
+
#ramps;
|
|
2124
|
+
#scheduledChanges;
|
|
1578
2125
|
#segments;
|
|
1579
2126
|
#settings;
|
|
1580
2127
|
#stats;
|
|
1581
2128
|
#webhooks;
|
|
2129
|
+
get changeRequests() {
|
|
2130
|
+
return this.#changeRequests ??= new ChangeRequestsResource(this._client, this._b);
|
|
2131
|
+
}
|
|
1582
2132
|
get changes() {
|
|
1583
2133
|
return this.#changes ??= new ChangesResource(this._client, this._b);
|
|
1584
2134
|
}
|
|
@@ -1594,6 +2144,12 @@ var FlagsResources = class extends APIResource {
|
|
|
1594
2144
|
get projects() {
|
|
1595
2145
|
return this.#projects ??= new ProjectsResource(this._client, this._b);
|
|
1596
2146
|
}
|
|
2147
|
+
get ramps() {
|
|
2148
|
+
return this.#ramps ??= new RampsResource(this._client, this._b);
|
|
2149
|
+
}
|
|
2150
|
+
get scheduledChanges() {
|
|
2151
|
+
return this.#scheduledChanges ??= new ScheduledChangesResource(this._client, this._b);
|
|
2152
|
+
}
|
|
1597
2153
|
get segments() {
|
|
1598
2154
|
return this.#segments ??= new SegmentsResource(this._client, this._b);
|
|
1599
2155
|
}
|
|
@@ -1610,21 +2166,31 @@ var FlagsResources = class extends APIResource {
|
|
|
1610
2166
|
|
|
1611
2167
|
// src/_generated/types.ts
|
|
1612
2168
|
var FlagsActorType = { values: ["user", "api_key", "system"] };
|
|
2169
|
+
var FlagsApprovalPolicy = { values: ["off", "everyone", "agents"] };
|
|
1613
2170
|
var FlagsChangeActorType = { values: ["user", "api_key", "system"] };
|
|
2171
|
+
var FlagsChangeRequestKind = { values: ["value", "ramp"] };
|
|
2172
|
+
var FlagsChangeRequestStatus = { values: ["pending", "approved", "scheduled", "applied", "rejected", "cancelled", "failed"] };
|
|
1614
2173
|
var FlagsEnvironmentPreset = { values: ["dev_prod", "dev_staging_prod"] };
|
|
2174
|
+
var FlagsEvaluationData = { values: ["not_collected"] };
|
|
1615
2175
|
var FlagsEvaluationErrorCode = { values: ["FLAG_NOT_FOUND", "TYPE_MISMATCH", "PREREQUISITE_CYCLE", "PREREQUISITE_NOT_FOUND", "PREREQUISITE_DEPTH", "GENERAL"] };
|
|
1616
2176
|
var FlagsEvaluationReason = { values: ["STATIC", "TARGETING_MATCH", "SPLIT", "DEFAULT", "ERROR"] };
|
|
1617
2177
|
var FlagsEvaluationWarningCode = { values: ["missing_user", "missing_attribute", "invalid_attribute", "unknown_comparator", "missing_percentage_attribute", "iso_date_converted"] };
|
|
2178
|
+
var FlagsGovernanceActorType = { values: ["user", "api_key", "system"] };
|
|
1618
2179
|
var FlagsHistoryExportFormat = { values: ["csv", "json"] };
|
|
1619
2180
|
var FlagsImportMappedType = { values: ["environment", "config", "segment", "setting"] };
|
|
1620
2181
|
var FlagsImportSource = { values: ["configcat"] };
|
|
1621
2182
|
var FlagsJsonPatchOp = { values: ["add", "remove", "replace"] };
|
|
1622
2183
|
var FlagsPrerequisiteComparator = { values: ["eq", "neq"] };
|
|
2184
|
+
var FlagsRampStatus = { values: ["active", "paused", "completed", "cancelled", "failed"] };
|
|
2185
|
+
var FlagsReviewDecision = { values: ["approved", "rejected"] };
|
|
2186
|
+
var FlagsScheduledChangeStatus = { values: ["pending", "applied", "failed", "cancelled"] };
|
|
2187
|
+
var FlagsScheduledOperation = { values: ["patch", "replace"] };
|
|
1623
2188
|
var FlagsSdkKeyRotationReason = { values: ["rotated", "grace_ended"] };
|
|
1624
2189
|
var FlagsSdkKeySlot = { values: ["primary", "secondary"] };
|
|
1625
2190
|
var FlagsSegmentComparator = { values: ["in", "not_in"] };
|
|
1626
|
-
var FlagsSettingLifecycle = { values: ["temporary", "permanent"] };
|
|
2191
|
+
var FlagsSettingLifecycle = { values: ["temporary", "permanent", "released", "deprecated"] };
|
|
1627
2192
|
var FlagsSettingType = { values: ["boolean", "string", "integer", "number", "json"] };
|
|
2193
|
+
var FlagsStaleReason = { values: ["no_recent_change", "rolled_out", "turned_off", "same_value_everywhere", "lifecycle_released", "lifecycle_deprecated"] };
|
|
1628
2194
|
var FlagsUserComparator = { values: ["eq", "neq", "one_of", "not_one_of", "contains_any", "not_contains_any", "starts_with_any", "not_starts_with_any", "ends_with_any", "not_ends_with_any", "semver_one_of", "semver_not_one_of", "semver_lt", "semver_lte", "semver_gt", "semver_gte", "num_eq", "num_neq", "num_lt", "num_lte", "num_gt", "num_gte", "before", "after", "array_contains_any", "array_not_contains_any", "eq_hashed", "neq_hashed", "one_of_hashed", "not_one_of_hashed", "starts_with_any_hashed", "not_starts_with_any_hashed", "ends_with_any_hashed", "not_ends_with_any_hashed", "array_contains_any_hashed", "array_not_contains_any_hashed"] };
|
|
1629
2195
|
var FlagsWebhookActorType = { values: ["user", "api_key", "system"] };
|
|
1630
2196
|
var SdkKeySlot = { values: ["primary", "secondary"] };
|
|
@@ -1632,10 +2198,10 @@ var WebhookAttemptTrigger = { values: ["automatic", "replay", "test"] };
|
|
|
1632
2198
|
var WebhookEndpointDisabledReason = { values: ["manual", "failing"] };
|
|
1633
2199
|
var WebhookEndpointStatus = { values: ["enabled", "disabled", "auto_disabled"] };
|
|
1634
2200
|
var WebhookEventStatus = { values: ["pending", "delivered", "failed", "not_sent"] };
|
|
1635
|
-
var WebhookEventType = { values: ["config.published", "sdk_key.rotated"] };
|
|
2201
|
+
var WebhookEventType = { values: ["config.published", "sdk_key.rotated", "change_request.created", "change_request.approved", "change_request.rejected", "change_request.applied", "change_request.cancelled"] };
|
|
1636
2202
|
|
|
1637
2203
|
// src/_generated/client.ts
|
|
1638
|
-
var VERSION = "0.
|
|
2204
|
+
var VERSION = "0.6.0" ;
|
|
1639
2205
|
exports.Flags = class Flags extends FlagsResources {
|
|
1640
2206
|
constructor(options = {}) {
|
|
1641
2207
|
super(new core.APIClient(options, core.PC_BASE_URL.flags, { name: "flags", version: VERSION }));
|
|
@@ -1648,21 +2214,31 @@ exports.Flags = class Flags extends FlagsResources {
|
|
|
1648
2214
|
};
|
|
1649
2215
|
((Flags2) => {
|
|
1650
2216
|
Flags2.FlagsActorType = FlagsActorType;
|
|
2217
|
+
Flags2.FlagsApprovalPolicy = FlagsApprovalPolicy;
|
|
1651
2218
|
Flags2.FlagsChangeActorType = FlagsChangeActorType;
|
|
2219
|
+
Flags2.FlagsChangeRequestKind = FlagsChangeRequestKind;
|
|
2220
|
+
Flags2.FlagsChangeRequestStatus = FlagsChangeRequestStatus;
|
|
1652
2221
|
Flags2.FlagsEnvironmentPreset = FlagsEnvironmentPreset;
|
|
2222
|
+
Flags2.FlagsEvaluationData = FlagsEvaluationData;
|
|
1653
2223
|
Flags2.FlagsEvaluationErrorCode = FlagsEvaluationErrorCode;
|
|
1654
2224
|
Flags2.FlagsEvaluationReason = FlagsEvaluationReason;
|
|
1655
2225
|
Flags2.FlagsEvaluationWarningCode = FlagsEvaluationWarningCode;
|
|
2226
|
+
Flags2.FlagsGovernanceActorType = FlagsGovernanceActorType;
|
|
1656
2227
|
Flags2.FlagsHistoryExportFormat = FlagsHistoryExportFormat;
|
|
1657
2228
|
Flags2.FlagsImportMappedType = FlagsImportMappedType;
|
|
1658
2229
|
Flags2.FlagsImportSource = FlagsImportSource;
|
|
1659
2230
|
Flags2.FlagsJsonPatchOp = FlagsJsonPatchOp;
|
|
1660
2231
|
Flags2.FlagsPrerequisiteComparator = FlagsPrerequisiteComparator;
|
|
2232
|
+
Flags2.FlagsRampStatus = FlagsRampStatus;
|
|
2233
|
+
Flags2.FlagsReviewDecision = FlagsReviewDecision;
|
|
2234
|
+
Flags2.FlagsScheduledChangeStatus = FlagsScheduledChangeStatus;
|
|
2235
|
+
Flags2.FlagsScheduledOperation = FlagsScheduledOperation;
|
|
1661
2236
|
Flags2.FlagsSdkKeyRotationReason = FlagsSdkKeyRotationReason;
|
|
1662
2237
|
Flags2.FlagsSdkKeySlot = FlagsSdkKeySlot;
|
|
1663
2238
|
Flags2.FlagsSegmentComparator = FlagsSegmentComparator;
|
|
1664
2239
|
Flags2.FlagsSettingLifecycle = FlagsSettingLifecycle;
|
|
1665
2240
|
Flags2.FlagsSettingType = FlagsSettingType;
|
|
2241
|
+
Flags2.FlagsStaleReason = FlagsStaleReason;
|
|
1666
2242
|
Flags2.FlagsUserComparator = FlagsUserComparator;
|
|
1667
2243
|
Flags2.FlagsWebhookActorType = FlagsWebhookActorType;
|
|
1668
2244
|
Flags2.SdkKeySlot = SdkKeySlot;
|
|
@@ -1672,5 +2248,5 @@ exports.Flags = class Flags extends FlagsResources {
|
|
|
1672
2248
|
Flags2.WebhookEventStatus = WebhookEventStatus;
|
|
1673
2249
|
Flags2.WebhookEventType = WebhookEventType;
|
|
1674
2250
|
})(exports.Flags || (exports.Flags = {}));
|
|
1675
|
-
//# sourceMappingURL=chunk-
|
|
1676
|
-
//# sourceMappingURL=chunk-
|
|
2251
|
+
//# sourceMappingURL=chunk-5SDZWOUP.cjs.map
|
|
2252
|
+
//# sourceMappingURL=chunk-5SDZWOUP.cjs.map
|