@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
|
@@ -17,6 +17,202 @@ var APIResource = class {
|
|
|
17
17
|
this._b = bound;
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
var ChangeRequestsResource = class extends APIResource {
|
|
21
|
+
/**
|
|
22
|
+
* Apply a change request
|
|
23
|
+
*
|
|
24
|
+
* 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.
|
|
25
|
+
*
|
|
26
|
+
* @param changeRequestId - Id of the change request.
|
|
27
|
+
* @param options - Per-request options.
|
|
28
|
+
* @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>`.
|
|
29
|
+
* @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.
|
|
30
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
31
|
+
* @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.
|
|
32
|
+
* @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`.
|
|
33
|
+
* @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.
|
|
34
|
+
* @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.
|
|
35
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/apply
|
|
36
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-apply
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const changeRequest = await flags.changeRequests.apply("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
apply(changeRequestId, options) {
|
|
43
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/apply", pathParams: { change_request_id: changeRequestId } }, options);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Approve a change request
|
|
47
|
+
*
|
|
48
|
+
* 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.
|
|
49
|
+
*
|
|
50
|
+
* @param changeRequestId - Id of the change request.
|
|
51
|
+
* @param params - `Flags.ChangeRequestApproveParams`.
|
|
52
|
+
* @param options - Per-request options.
|
|
53
|
+
* @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>`.
|
|
54
|
+
* @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.
|
|
55
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
56
|
+
* @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.
|
|
57
|
+
* @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`.
|
|
58
|
+
* @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.
|
|
59
|
+
* @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.
|
|
60
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/approve
|
|
61
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-approve
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const changeRequest = await flags.changeRequests.approve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { apply: true });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
approve(changeRequestId, params, options) {
|
|
68
|
+
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);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Cancel a change request
|
|
72
|
+
*
|
|
73
|
+
* Withdraws an open request (and its schedule). The author can always cancel; anyone else needs the right to make the write.
|
|
74
|
+
*
|
|
75
|
+
* @param changeRequestId - Id of the change request.
|
|
76
|
+
* @param params - `Flags.ChangeRequestCancelParams`.
|
|
77
|
+
* @param options - Per-request options.
|
|
78
|
+
* @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>`.
|
|
79
|
+
* @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.
|
|
80
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
81
|
+
* @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).
|
|
82
|
+
* @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.
|
|
83
|
+
* @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.
|
|
84
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/cancel
|
|
85
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-cancel
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const changeRequest = await flags.changeRequests.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
cancel(changeRequestId, params, options) {
|
|
92
|
+
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);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* List change requests
|
|
96
|
+
*
|
|
97
|
+
* The workspace's change requests, newest first. `status=open` is the review queue (pending, approved, scheduled and failed requests).
|
|
98
|
+
*
|
|
99
|
+
* @param params - `Flags.ChangeRequestListParams`.
|
|
100
|
+
* @param options - Per-request options.
|
|
101
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad filter, cursor or `limit`.
|
|
102
|
+
* @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>`.
|
|
103
|
+
* @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`).
|
|
104
|
+
* @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.
|
|
105
|
+
* @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.
|
|
106
|
+
* @see GET /v1/workspaces/{workspace_id}/change-requests
|
|
107
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-change-requests
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* for await (const changeRequest of flags.changeRequests.list()) {
|
|
111
|
+
* console.log(changeRequest);
|
|
112
|
+
* }
|
|
113
|
+
* const page = await flags.changeRequests.list({}, { timeout: 5_000 });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
list(params, options) {
|
|
117
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/change-requests", query: params }, options);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Rebase a change request
|
|
121
|
+
*
|
|
122
|
+
* 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).
|
|
123
|
+
*
|
|
124
|
+
* @param changeRequestId - Id of the change request.
|
|
125
|
+
* @param options - Per-request options.
|
|
126
|
+
* @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>`.
|
|
127
|
+
* @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.
|
|
128
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
129
|
+
* @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).
|
|
130
|
+
* @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`.
|
|
131
|
+
* @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.
|
|
132
|
+
* @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.
|
|
133
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/rebase
|
|
134
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-rebase
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const changeRequest = await flags.changeRequests.rebase("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
rebase(changeRequestId, options) {
|
|
141
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}/rebase", pathParams: { change_request_id: changeRequestId } }, options);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Reject a change request
|
|
145
|
+
*
|
|
146
|
+
* Rejects the request (final); the author is emailed with your note. Same reviewer rules as approve.
|
|
147
|
+
*
|
|
148
|
+
* @param changeRequestId - Id of the change request.
|
|
149
|
+
* @param params - `Flags.ChangeRequestRejectParams`.
|
|
150
|
+
* @param options - Per-request options.
|
|
151
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: `apply` is only for approvals.
|
|
152
|
+
* @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>`.
|
|
153
|
+
* @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.
|
|
154
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
155
|
+
* @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.
|
|
156
|
+
* @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.
|
|
157
|
+
* @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.
|
|
158
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/reject
|
|
159
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-reject
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* const changeRequest = await flags.changeRequests.reject("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { apply: true });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
reject(changeRequestId, params, options) {
|
|
166
|
+
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);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get a change request
|
|
170
|
+
*
|
|
171
|
+
* One change request with its diff, reviews and whether it is `stale`.
|
|
172
|
+
*
|
|
173
|
+
* @param changeRequestId - Id of the change request.
|
|
174
|
+
* @param options - Per-request options.
|
|
175
|
+
* @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>`.
|
|
176
|
+
* @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`).
|
|
177
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
178
|
+
* @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.
|
|
179
|
+
* @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.
|
|
180
|
+
* @see GET /v1/workspaces/{workspace_id}/change-requests/{change_request_id}
|
|
181
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-change-requests-change-request-id
|
|
182
|
+
* @example
|
|
183
|
+
* ```ts
|
|
184
|
+
* const changeRequest = await flags.changeRequests.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
retrieve(changeRequestId, options) {
|
|
188
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/change-requests/{change_request_id}", pathParams: { change_request_id: changeRequestId } }, options);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Schedule a change request
|
|
192
|
+
*
|
|
193
|
+
* 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.
|
|
194
|
+
*
|
|
195
|
+
* @param changeRequestId - Id of the change request.
|
|
196
|
+
* @param params - `Flags.ChangeRequestScheduleParams`.
|
|
197
|
+
* @param options - Per-request options.
|
|
198
|
+
* @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>`.
|
|
199
|
+
* @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.
|
|
200
|
+
* @throws {NotFoundError} 404 NOT_FOUND, CHANGE_REQUEST_NOT_FOUND: `CHANGE_REQUEST_NOT_FOUND`: no such change request in this workspace.
|
|
201
|
+
* @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).
|
|
202
|
+
* @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).
|
|
203
|
+
* @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.
|
|
204
|
+
* @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.
|
|
205
|
+
* @see POST /v1/workspaces/{workspace_id}/change-requests/{change_request_id}/schedule
|
|
206
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-change-requests-change-request-id-schedule
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const changeRequest = await flags.changeRequests.schedule("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { run_at: "2026-11-20T09:00:00.000Z" });
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
schedule(changeRequestId, params, options) {
|
|
213
|
+
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);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
20
216
|
var ChangesResource = class extends APIResource {
|
|
21
217
|
/**
|
|
22
218
|
* Get a change
|
|
@@ -742,7 +938,7 @@ var ProjectsEnvironmentsResource = class extends APIResource {
|
|
|
742
938
|
/**
|
|
743
939
|
* Update an environment
|
|
744
940
|
*
|
|
745
|
-
* Name, color, order, `protected` and `
|
|
941
|
+
* 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.
|
|
746
942
|
*
|
|
747
943
|
* @param projectId - Id of the project.
|
|
748
944
|
* @param environmentId - Id of the environment.
|
|
@@ -750,7 +946,7 @@ var ProjectsEnvironmentsResource = class extends APIResource {
|
|
|
750
946
|
* @param options - Per-request options.
|
|
751
947
|
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is invalid.
|
|
752
948
|
* @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>`.
|
|
753
|
-
* @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`).
|
|
949
|
+
* @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`.
|
|
754
950
|
* @throws {NotFoundError} 404 NOT_FOUND, ENVIRONMENT_NOT_FOUND: `ENVIRONMENT_NOT_FOUND`: no such environment in this project.
|
|
755
951
|
* @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.
|
|
756
952
|
* @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.
|
|
@@ -758,7 +954,7 @@ var ProjectsEnvironmentsResource = class extends APIResource {
|
|
|
758
954
|
* @see https://productcraft.co/docs/flags/api-reference#patch-v1-workspaces-workspace-id-projects-project-id-environments-environment-id
|
|
759
955
|
* @example
|
|
760
956
|
* ```ts
|
|
761
|
-
* const environment = await flags.projects.environments.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", {
|
|
957
|
+
* const environment = await flags.projects.environments.update("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { approval_policy: "off" });
|
|
762
958
|
* ```
|
|
763
959
|
*/
|
|
764
960
|
update(projectId, environmentId, params, options) {
|
|
@@ -827,11 +1023,63 @@ var ProjectsSegmentsResource = class extends APIResource {
|
|
|
827
1023
|
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/projects/{project_id}/segments", pathParams: { project_id: projectId }, query: params }, options);
|
|
828
1024
|
}
|
|
829
1025
|
};
|
|
1026
|
+
var ProjectsStaleFlagsResource = class extends APIResource {
|
|
1027
|
+
/**
|
|
1028
|
+
* List stale flags
|
|
1029
|
+
*
|
|
1030
|
+
* 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`).
|
|
1031
|
+
*
|
|
1032
|
+
* @param projectId - Id of the project.
|
|
1033
|
+
* @param params - `Flags.ProjectStaleFlagListParams`.
|
|
1034
|
+
* @param options - Per-request options.
|
|
1035
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad `days`, `reason`, cursor or `limit`.
|
|
1036
|
+
* @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>`.
|
|
1037
|
+
* @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`).
|
|
1038
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PROJECT_NOT_FOUND: `PROJECT_NOT_FOUND`: no such project in this workspace.
|
|
1039
|
+
* @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.
|
|
1040
|
+
* @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.
|
|
1041
|
+
* @see GET /v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags
|
|
1042
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-projects-project-id-stale-flags
|
|
1043
|
+
* @example
|
|
1044
|
+
* ```ts
|
|
1045
|
+
* for await (const staleFlag of flags.projects.staleFlags.list("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f")) {
|
|
1046
|
+
* console.log(staleFlag);
|
|
1047
|
+
* }
|
|
1048
|
+
* const page = await flags.projects.staleFlags.list("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", {}, { timeout: 5_000 });
|
|
1049
|
+
* ```
|
|
1050
|
+
*/
|
|
1051
|
+
list(projectId, params, options) {
|
|
1052
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags", pathParams: { project_id: projectId }, query: params }, options);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Send the stale-flag digest now
|
|
1056
|
+
*
|
|
1057
|
+
* 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.
|
|
1058
|
+
*
|
|
1059
|
+
* @param projectId - Id of the project.
|
|
1060
|
+
* @param options - Per-request options.
|
|
1061
|
+
* @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>`.
|
|
1062
|
+
* @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`).
|
|
1063
|
+
* @throws {NotFoundError} 404 NOT_FOUND, PROJECT_NOT_FOUND: `PROJECT_NOT_FOUND`: no such project in this workspace.
|
|
1064
|
+
* @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.
|
|
1065
|
+
* @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.
|
|
1066
|
+
* @see POST /v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags/digest
|
|
1067
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-projects-project-id-stale-flags-digest
|
|
1068
|
+
* @example
|
|
1069
|
+
* ```ts
|
|
1070
|
+
* const staleDigest = await flags.projects.staleFlags.sendDigest("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
1071
|
+
* ```
|
|
1072
|
+
*/
|
|
1073
|
+
sendDigest(projectId, options) {
|
|
1074
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/projects/{project_id}/stale-flags/digest", pathParams: { project_id: projectId } }, options);
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
830
1077
|
var ProjectsResource = class extends APIResource {
|
|
831
1078
|
#changes;
|
|
832
1079
|
#configs;
|
|
833
1080
|
#environments;
|
|
834
1081
|
#segments;
|
|
1082
|
+
#staleFlags;
|
|
835
1083
|
get changes() {
|
|
836
1084
|
return this.#changes ??= new ProjectsChangesResource(this._client, this._b);
|
|
837
1085
|
}
|
|
@@ -844,6 +1092,9 @@ var ProjectsResource = class extends APIResource {
|
|
|
844
1092
|
get segments() {
|
|
845
1093
|
return this.#segments ??= new ProjectsSegmentsResource(this._client, this._b);
|
|
846
1094
|
}
|
|
1095
|
+
get staleFlags() {
|
|
1096
|
+
return this.#staleFlags ??= new ProjectsStaleFlagsResource(this._client, this._b);
|
|
1097
|
+
}
|
|
847
1098
|
/**
|
|
848
1099
|
* Create a project
|
|
849
1100
|
*
|
|
@@ -965,6 +1216,200 @@ var ProjectsResource = class extends APIResource {
|
|
|
965
1216
|
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/projects/{project_id}", pathParams: { project_id: projectId }, body: params }, options);
|
|
966
1217
|
}
|
|
967
1218
|
};
|
|
1219
|
+
var RampsResource = class extends APIResource {
|
|
1220
|
+
/**
|
|
1221
|
+
* Cancel a ramp
|
|
1222
|
+
*
|
|
1223
|
+
* Stops the ramp where it is: the split it reached stays. Change or restore the value to undo it.
|
|
1224
|
+
*
|
|
1225
|
+
* @param rampId - Id of the ramp.
|
|
1226
|
+
* @param params - `Flags.RampCancelParams`.
|
|
1227
|
+
* @param options - Per-request options.
|
|
1228
|
+
* @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>`.
|
|
1229
|
+
* @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.
|
|
1230
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1231
|
+
* @throws {ConflictError} 409 CONFLICT, RAMP_NOT_LIVE: `RAMP_NOT_LIVE`: the ramp already completed, failed or was cancelled.
|
|
1232
|
+
* @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.
|
|
1233
|
+
* @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.
|
|
1234
|
+
* @see POST /v1/workspaces/{workspace_id}/ramps/{ramp_id}/cancel
|
|
1235
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-ramps-ramp-id-cancel
|
|
1236
|
+
* @example
|
|
1237
|
+
* ```ts
|
|
1238
|
+
* const ramp = await flags.ramps.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1239
|
+
* ```
|
|
1240
|
+
*/
|
|
1241
|
+
cancel(rampId, params, options) {
|
|
1242
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}/cancel", pathParams: { ramp_id: rampId }, body: params }, options);
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* List ramps
|
|
1246
|
+
*
|
|
1247
|
+
* Percentage ramps, newest first. Filter by `status` (`active`, `paused`, `completed`, `cancelled`, `failed`), project, environment or setting.
|
|
1248
|
+
*
|
|
1249
|
+
* @param params - `Flags.RampListParams`.
|
|
1250
|
+
* @param options - Per-request options.
|
|
1251
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad filter, cursor or `limit`.
|
|
1252
|
+
* @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>`.
|
|
1253
|
+
* @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`).
|
|
1254
|
+
* @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.
|
|
1255
|
+
* @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.
|
|
1256
|
+
* @see GET /v1/workspaces/{workspace_id}/ramps
|
|
1257
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-ramps
|
|
1258
|
+
* @example
|
|
1259
|
+
* ```ts
|
|
1260
|
+
* for await (const ramp of flags.ramps.list()) {
|
|
1261
|
+
* console.log(ramp);
|
|
1262
|
+
* }
|
|
1263
|
+
* const page = await flags.ramps.list({}, { timeout: 5_000 });
|
|
1264
|
+
* ```
|
|
1265
|
+
*/
|
|
1266
|
+
list(params, options) {
|
|
1267
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/ramps", query: params }, options);
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Pause a ramp
|
|
1271
|
+
*
|
|
1272
|
+
* 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).
|
|
1273
|
+
*
|
|
1274
|
+
* @param rampId - Id of the ramp.
|
|
1275
|
+
* @param params - `Flags.RampPauseParams`.
|
|
1276
|
+
* @param options - Per-request options.
|
|
1277
|
+
* @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>`.
|
|
1278
|
+
* @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.
|
|
1279
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1280
|
+
* @throws {ConflictError} 409 CONFLICT, RAMP_NOT_LIVE: `RAMP_NOT_LIVE`: the ramp is not active.
|
|
1281
|
+
* @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.
|
|
1282
|
+
* @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.
|
|
1283
|
+
* @see POST /v1/workspaces/{workspace_id}/ramps/{ramp_id}/pause
|
|
1284
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-ramps-ramp-id-pause
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```ts
|
|
1287
|
+
* const ramp = await flags.ramps.pause("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1288
|
+
* ```
|
|
1289
|
+
*/
|
|
1290
|
+
pause(rampId, params, options) {
|
|
1291
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}/pause", pathParams: { ramp_id: rampId }, body: params }, options);
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Resume a ramp
|
|
1295
|
+
*
|
|
1296
|
+
* 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.
|
|
1297
|
+
*
|
|
1298
|
+
* @param rampId - Id of the ramp.
|
|
1299
|
+
* @param params - `Flags.RampResumeParams`.
|
|
1300
|
+
* @param options - Per-request options.
|
|
1301
|
+
* @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>`.
|
|
1302
|
+
* @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.
|
|
1303
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1304
|
+
* @throws {ConflictError} 409 CONFLICT, RAMP_NOT_LIVE: `RAMP_NOT_LIVE`: the ramp is not paused.
|
|
1305
|
+
* @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.
|
|
1306
|
+
* @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.
|
|
1307
|
+
* @see POST /v1/workspaces/{workspace_id}/ramps/{ramp_id}/resume
|
|
1308
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-ramps-ramp-id-resume
|
|
1309
|
+
* @example
|
|
1310
|
+
* ```ts
|
|
1311
|
+
* const ramp = await flags.ramps.resume("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1312
|
+
* ```
|
|
1313
|
+
*/
|
|
1314
|
+
resume(rampId, params, options) {
|
|
1315
|
+
return this._client.request({ method: "POST", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}/resume", pathParams: { ramp_id: rampId }, body: params }, options);
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Get a ramp
|
|
1319
|
+
*
|
|
1320
|
+
* One ramp with its steps, the percentage it reached and its state.
|
|
1321
|
+
*
|
|
1322
|
+
* @param rampId - Id of the ramp.
|
|
1323
|
+
* @param options - Per-request options.
|
|
1324
|
+
* @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>`.
|
|
1325
|
+
* @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`).
|
|
1326
|
+
* @throws {NotFoundError} 404 NOT_FOUND, RAMP_NOT_FOUND: `RAMP_NOT_FOUND`: no such ramp in this workspace.
|
|
1327
|
+
* @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.
|
|
1328
|
+
* @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.
|
|
1329
|
+
* @see GET /v1/workspaces/{workspace_id}/ramps/{ramp_id}
|
|
1330
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-ramps-ramp-id
|
|
1331
|
+
* @example
|
|
1332
|
+
* ```ts
|
|
1333
|
+
* const ramp = await flags.ramps.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
1334
|
+
* ```
|
|
1335
|
+
*/
|
|
1336
|
+
retrieve(rampId, options) {
|
|
1337
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/ramps/{ramp_id}", pathParams: { ramp_id: rampId } }, options);
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
var ScheduledChangesResource = class extends APIResource {
|
|
1341
|
+
/**
|
|
1342
|
+
* Cancel a scheduled change
|
|
1343
|
+
*
|
|
1344
|
+
* Cancels a pending scheduled change. A scheduled change request goes back to `approved`.
|
|
1345
|
+
*
|
|
1346
|
+
* @param scheduledChangeId - Id of the scheduled change.
|
|
1347
|
+
* @param params - `Flags.ScheduledChangeCancelParams`.
|
|
1348
|
+
* @param options - Per-request options.
|
|
1349
|
+
* @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>`.
|
|
1350
|
+
* @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.
|
|
1351
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SCHEDULED_CHANGE_NOT_FOUND: `SCHEDULED_CHANGE_NOT_FOUND`: no such scheduled change in this workspace.
|
|
1352
|
+
* @throws {ConflictError} 409 CONFLICT, SCHEDULED_CHANGE_NOT_PENDING: `SCHEDULED_CHANGE_NOT_PENDING`: it already ran or was cancelled.
|
|
1353
|
+
* @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.
|
|
1354
|
+
* @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.
|
|
1355
|
+
* @see POST /v1/workspaces/{workspace_id}/scheduled-changes/{scheduled_change_id}/cancel
|
|
1356
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-scheduled-changes-scheduled-change-id-cancel
|
|
1357
|
+
* @example
|
|
1358
|
+
* ```ts
|
|
1359
|
+
* const scheduledChange = await flags.scheduledChanges.cancel("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { note: "Roll out the new checkout to everyone (FLAG-142)" });
|
|
1360
|
+
* ```
|
|
1361
|
+
*/
|
|
1362
|
+
cancel(scheduledChangeId, params, options) {
|
|
1363
|
+
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);
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* List scheduled changes
|
|
1367
|
+
*
|
|
1368
|
+
* Scheduled value changes, soonest first. Filter by `status` (`pending`, `applied`, `failed`, `cancelled`), project, environment or setting.
|
|
1369
|
+
*
|
|
1370
|
+
* @param params - `Flags.ScheduledChangeListParams`.
|
|
1371
|
+
* @param options - Per-request options.
|
|
1372
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a bad filter, cursor or `limit`.
|
|
1373
|
+
* @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>`.
|
|
1374
|
+
* @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`).
|
|
1375
|
+
* @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.
|
|
1376
|
+
* @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.
|
|
1377
|
+
* @see GET /v1/workspaces/{workspace_id}/scheduled-changes
|
|
1378
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-scheduled-changes
|
|
1379
|
+
* @example
|
|
1380
|
+
* ```ts
|
|
1381
|
+
* for await (const scheduledChange of flags.scheduledChanges.list()) {
|
|
1382
|
+
* console.log(scheduledChange);
|
|
1383
|
+
* }
|
|
1384
|
+
* const page = await flags.scheduledChanges.list({}, { timeout: 5_000 });
|
|
1385
|
+
* ```
|
|
1386
|
+
*/
|
|
1387
|
+
list(params, options) {
|
|
1388
|
+
return this._client.list({ method: "GET", path: "/v1/workspaces/{workspace_id}/scheduled-changes", query: params }, options);
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Get a scheduled change
|
|
1392
|
+
*
|
|
1393
|
+
* One scheduled change, with what it will write and, once run, the history entry or the error.
|
|
1394
|
+
*
|
|
1395
|
+
* @param scheduledChangeId - Id of the scheduled change.
|
|
1396
|
+
* @param options - Per-request options.
|
|
1397
|
+
* @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>`.
|
|
1398
|
+
* @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`).
|
|
1399
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SCHEDULED_CHANGE_NOT_FOUND: `SCHEDULED_CHANGE_NOT_FOUND`: no such scheduled change in this workspace.
|
|
1400
|
+
* @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.
|
|
1401
|
+
* @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.
|
|
1402
|
+
* @see GET /v1/workspaces/{workspace_id}/scheduled-changes/{scheduled_change_id}
|
|
1403
|
+
* @see https://productcraft.co/docs/flags/api-reference#get-v1-workspaces-workspace-id-scheduled-changes-scheduled-change-id
|
|
1404
|
+
* @example
|
|
1405
|
+
* ```ts
|
|
1406
|
+
* const scheduledChange = await flags.scheduledChanges.retrieve("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f");
|
|
1407
|
+
* ```
|
|
1408
|
+
*/
|
|
1409
|
+
retrieve(scheduledChangeId, options) {
|
|
1410
|
+
return this._client.request({ method: "GET", path: "/v1/workspaces/{workspace_id}/scheduled-changes/{scheduled_change_id}", pathParams: { scheduled_change_id: scheduledChangeId } }, options);
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
968
1413
|
var SegmentsResource = class extends APIResource {
|
|
969
1414
|
/**
|
|
970
1415
|
* Delete a segment
|
|
@@ -1062,7 +1507,106 @@ var SegmentsResource = class extends APIResource {
|
|
|
1062
1507
|
return this._client.request({ method: "PATCH", path: "/v1/workspaces/{workspace_id}/segments/{segment_id}", pathParams: { segment_id: segmentId }, body: params }, options);
|
|
1063
1508
|
}
|
|
1064
1509
|
};
|
|
1510
|
+
var SettingsValuesChangeRequestsResource = class extends APIResource {
|
|
1511
|
+
/**
|
|
1512
|
+
* Propose a change
|
|
1513
|
+
*
|
|
1514
|
+
* 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.
|
|
1515
|
+
*
|
|
1516
|
+
* @param settingId - Id of the setting.
|
|
1517
|
+
* @param environmentId - Id of an environment of the same project.
|
|
1518
|
+
* @param params - `Flags.SettingsValueChangeRequestCreateParams`.
|
|
1519
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1520
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field does not fit the `operation`, or is missing.
|
|
1521
|
+
* @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>`.
|
|
1522
|
+
* @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.
|
|
1523
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SETTING_NOT_FOUND, ENVIRONMENT_NOT_FOUND: `SETTING_NOT_FOUND` or `ENVIRONMENT_NOT_FOUND`.
|
|
1524
|
+
* @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).
|
|
1525
|
+
* @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`.
|
|
1526
|
+
* @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.
|
|
1527
|
+
* @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.
|
|
1528
|
+
* @see POST /v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/change-requests
|
|
1529
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-settings-setting-id-values-environment-id-change-requests
|
|
1530
|
+
* @example
|
|
1531
|
+
* ```ts
|
|
1532
|
+
* const changeRequest = await flags.settings.values.changeRequests.create("3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", "3f0c3c1e-8a2b-4c55-9d3f-0a1b2c3d4e5f", { operation: "patch", version: 7 });
|
|
1533
|
+
* ```
|
|
1534
|
+
*/
|
|
1535
|
+
create(settingId, environmentId, params, options) {
|
|
1536
|
+
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);
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
var SettingsValuesRampsResource = class extends APIResource {
|
|
1540
|
+
/**
|
|
1541
|
+
* Start a ramp
|
|
1542
|
+
*
|
|
1543
|
+
* 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`.
|
|
1544
|
+
*
|
|
1545
|
+
* @param settingId - Id of the setting.
|
|
1546
|
+
* @param environmentId - Id of an environment of the same project.
|
|
1547
|
+
* @param params - `Flags.SettingsValueRampCreateParams`.
|
|
1548
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1549
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field is missing or invalid.
|
|
1550
|
+
* @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>`.
|
|
1551
|
+
* @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.
|
|
1552
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SETTING_NOT_FOUND, ENVIRONMENT_NOT_FOUND: `SETTING_NOT_FOUND` or `ENVIRONMENT_NOT_FOUND`.
|
|
1553
|
+
* @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).
|
|
1554
|
+
* @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`.
|
|
1555
|
+
* @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.
|
|
1556
|
+
* @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.
|
|
1557
|
+
* @see POST /v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/ramps
|
|
1558
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-settings-setting-id-values-environment-id-ramps
|
|
1559
|
+
* @example
|
|
1560
|
+
* ```ts
|
|
1561
|
+
* 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 });
|
|
1562
|
+
* ```
|
|
1563
|
+
*/
|
|
1564
|
+
create(settingId, environmentId, params, options) {
|
|
1565
|
+
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);
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
var SettingsValuesScheduledChangesResource = class extends APIResource {
|
|
1569
|
+
/**
|
|
1570
|
+
* Schedule a change
|
|
1571
|
+
*
|
|
1572
|
+
* 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.
|
|
1573
|
+
*
|
|
1574
|
+
* @param settingId - Id of the setting.
|
|
1575
|
+
* @param environmentId - Id of an environment of the same project.
|
|
1576
|
+
* @param params - `Flags.SettingsValueScheduledChangeCreateParams`.
|
|
1577
|
+
* @param options - Per-request options (an Idempotency-Key is sent automatically; override with `idempotencyKey`).
|
|
1578
|
+
* @throws {BadRequestError} 400 BAD_REQUEST, VALIDATION_ERROR: `VALIDATION_ERROR`: a field does not fit the `operation`.
|
|
1579
|
+
* @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>`.
|
|
1580
|
+
* @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.
|
|
1581
|
+
* @throws {NotFoundError} 404 NOT_FOUND, SETTING_NOT_FOUND, ENVIRONMENT_NOT_FOUND: `SETTING_NOT_FOUND` or `ENVIRONMENT_NOT_FOUND`.
|
|
1582
|
+
* @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).
|
|
1583
|
+
* @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`.
|
|
1584
|
+
* @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.
|
|
1585
|
+
* @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.
|
|
1586
|
+
* @see POST /v1/workspaces/{workspace_id}/settings/{setting_id}/values/{environment_id}/scheduled-changes
|
|
1587
|
+
* @see https://productcraft.co/docs/flags/api-reference#post-v1-workspaces-workspace-id-settings-setting-id-values-environment-id-scheduled-changes
|
|
1588
|
+
* @example
|
|
1589
|
+
* ```ts
|
|
1590
|
+
* 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" });
|
|
1591
|
+
* ```
|
|
1592
|
+
*/
|
|
1593
|
+
create(settingId, environmentId, params, options) {
|
|
1594
|
+
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);
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1065
1597
|
var SettingsValuesResource = class extends APIResource {
|
|
1598
|
+
#changeRequests;
|
|
1599
|
+
#ramps;
|
|
1600
|
+
#scheduledChanges;
|
|
1601
|
+
get changeRequests() {
|
|
1602
|
+
return this.#changeRequests ??= new SettingsValuesChangeRequestsResource(this._client, this._b);
|
|
1603
|
+
}
|
|
1604
|
+
get ramps() {
|
|
1605
|
+
return this.#ramps ??= new SettingsValuesRampsResource(this._client, this._b);
|
|
1606
|
+
}
|
|
1607
|
+
get scheduledChanges() {
|
|
1608
|
+
return this.#scheduledChanges ??= new SettingsValuesScheduledChangesResource(this._client, this._b);
|
|
1609
|
+
}
|
|
1066
1610
|
/**
|
|
1067
1611
|
* Replace a value
|
|
1068
1612
|
*
|
|
@@ -1568,15 +2112,21 @@ var WebhooksResource = class extends APIResource {
|
|
|
1568
2112
|
}
|
|
1569
2113
|
};
|
|
1570
2114
|
var FlagsResources = class extends APIResource {
|
|
2115
|
+
#changeRequests;
|
|
1571
2116
|
#changes;
|
|
1572
2117
|
#configs;
|
|
1573
2118
|
#imports;
|
|
1574
2119
|
#limits;
|
|
1575
2120
|
#projects;
|
|
2121
|
+
#ramps;
|
|
2122
|
+
#scheduledChanges;
|
|
1576
2123
|
#segments;
|
|
1577
2124
|
#settings;
|
|
1578
2125
|
#stats;
|
|
1579
2126
|
#webhooks;
|
|
2127
|
+
get changeRequests() {
|
|
2128
|
+
return this.#changeRequests ??= new ChangeRequestsResource(this._client, this._b);
|
|
2129
|
+
}
|
|
1580
2130
|
get changes() {
|
|
1581
2131
|
return this.#changes ??= new ChangesResource(this._client, this._b);
|
|
1582
2132
|
}
|
|
@@ -1592,6 +2142,12 @@ var FlagsResources = class extends APIResource {
|
|
|
1592
2142
|
get projects() {
|
|
1593
2143
|
return this.#projects ??= new ProjectsResource(this._client, this._b);
|
|
1594
2144
|
}
|
|
2145
|
+
get ramps() {
|
|
2146
|
+
return this.#ramps ??= new RampsResource(this._client, this._b);
|
|
2147
|
+
}
|
|
2148
|
+
get scheduledChanges() {
|
|
2149
|
+
return this.#scheduledChanges ??= new ScheduledChangesResource(this._client, this._b);
|
|
2150
|
+
}
|
|
1595
2151
|
get segments() {
|
|
1596
2152
|
return this.#segments ??= new SegmentsResource(this._client, this._b);
|
|
1597
2153
|
}
|
|
@@ -1608,21 +2164,31 @@ var FlagsResources = class extends APIResource {
|
|
|
1608
2164
|
|
|
1609
2165
|
// src/_generated/types.ts
|
|
1610
2166
|
var FlagsActorType = { values: ["user", "api_key", "system"] };
|
|
2167
|
+
var FlagsApprovalPolicy = { values: ["off", "everyone", "agents"] };
|
|
1611
2168
|
var FlagsChangeActorType = { values: ["user", "api_key", "system"] };
|
|
2169
|
+
var FlagsChangeRequestKind = { values: ["value", "ramp"] };
|
|
2170
|
+
var FlagsChangeRequestStatus = { values: ["pending", "approved", "scheduled", "applied", "rejected", "cancelled", "failed"] };
|
|
1612
2171
|
var FlagsEnvironmentPreset = { values: ["dev_prod", "dev_staging_prod"] };
|
|
2172
|
+
var FlagsEvaluationData = { values: ["not_collected"] };
|
|
1613
2173
|
var FlagsEvaluationErrorCode = { values: ["FLAG_NOT_FOUND", "TYPE_MISMATCH", "PREREQUISITE_CYCLE", "PREREQUISITE_NOT_FOUND", "PREREQUISITE_DEPTH", "GENERAL"] };
|
|
1614
2174
|
var FlagsEvaluationReason = { values: ["STATIC", "TARGETING_MATCH", "SPLIT", "DEFAULT", "ERROR"] };
|
|
1615
2175
|
var FlagsEvaluationWarningCode = { values: ["missing_user", "missing_attribute", "invalid_attribute", "unknown_comparator", "missing_percentage_attribute", "iso_date_converted"] };
|
|
2176
|
+
var FlagsGovernanceActorType = { values: ["user", "api_key", "system"] };
|
|
1616
2177
|
var FlagsHistoryExportFormat = { values: ["csv", "json"] };
|
|
1617
2178
|
var FlagsImportMappedType = { values: ["environment", "config", "segment", "setting"] };
|
|
1618
2179
|
var FlagsImportSource = { values: ["configcat"] };
|
|
1619
2180
|
var FlagsJsonPatchOp = { values: ["add", "remove", "replace"] };
|
|
1620
2181
|
var FlagsPrerequisiteComparator = { values: ["eq", "neq"] };
|
|
2182
|
+
var FlagsRampStatus = { values: ["active", "paused", "completed", "cancelled", "failed"] };
|
|
2183
|
+
var FlagsReviewDecision = { values: ["approved", "rejected"] };
|
|
2184
|
+
var FlagsScheduledChangeStatus = { values: ["pending", "applied", "failed", "cancelled"] };
|
|
2185
|
+
var FlagsScheduledOperation = { values: ["patch", "replace"] };
|
|
1621
2186
|
var FlagsSdkKeyRotationReason = { values: ["rotated", "grace_ended"] };
|
|
1622
2187
|
var FlagsSdkKeySlot = { values: ["primary", "secondary"] };
|
|
1623
2188
|
var FlagsSegmentComparator = { values: ["in", "not_in"] };
|
|
1624
|
-
var FlagsSettingLifecycle = { values: ["temporary", "permanent"] };
|
|
2189
|
+
var FlagsSettingLifecycle = { values: ["temporary", "permanent", "released", "deprecated"] };
|
|
1625
2190
|
var FlagsSettingType = { values: ["boolean", "string", "integer", "number", "json"] };
|
|
2191
|
+
var FlagsStaleReason = { values: ["no_recent_change", "rolled_out", "turned_off", "same_value_everywhere", "lifecycle_released", "lifecycle_deprecated"] };
|
|
1626
2192
|
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"] };
|
|
1627
2193
|
var FlagsWebhookActorType = { values: ["user", "api_key", "system"] };
|
|
1628
2194
|
var SdkKeySlot = { values: ["primary", "secondary"] };
|
|
@@ -1630,10 +2196,10 @@ var WebhookAttemptTrigger = { values: ["automatic", "replay", "test"] };
|
|
|
1630
2196
|
var WebhookEndpointDisabledReason = { values: ["manual", "failing"] };
|
|
1631
2197
|
var WebhookEndpointStatus = { values: ["enabled", "disabled", "auto_disabled"] };
|
|
1632
2198
|
var WebhookEventStatus = { values: ["pending", "delivered", "failed", "not_sent"] };
|
|
1633
|
-
var WebhookEventType = { values: ["config.published", "sdk_key.rotated"] };
|
|
2199
|
+
var WebhookEventType = { values: ["config.published", "sdk_key.rotated", "change_request.created", "change_request.approved", "change_request.rejected", "change_request.applied", "change_request.cancelled"] };
|
|
1634
2200
|
|
|
1635
2201
|
// src/_generated/client.ts
|
|
1636
|
-
var VERSION = "0.
|
|
2202
|
+
var VERSION = "0.6.0" ;
|
|
1637
2203
|
var Flags = class extends FlagsResources {
|
|
1638
2204
|
constructor(options = {}) {
|
|
1639
2205
|
super(new APIClient(options, PC_BASE_URL.flags, { name: "flags", version: VERSION }));
|
|
@@ -1646,21 +2212,31 @@ var Flags = class extends FlagsResources {
|
|
|
1646
2212
|
};
|
|
1647
2213
|
((Flags2) => {
|
|
1648
2214
|
Flags2.FlagsActorType = FlagsActorType;
|
|
2215
|
+
Flags2.FlagsApprovalPolicy = FlagsApprovalPolicy;
|
|
1649
2216
|
Flags2.FlagsChangeActorType = FlagsChangeActorType;
|
|
2217
|
+
Flags2.FlagsChangeRequestKind = FlagsChangeRequestKind;
|
|
2218
|
+
Flags2.FlagsChangeRequestStatus = FlagsChangeRequestStatus;
|
|
1650
2219
|
Flags2.FlagsEnvironmentPreset = FlagsEnvironmentPreset;
|
|
2220
|
+
Flags2.FlagsEvaluationData = FlagsEvaluationData;
|
|
1651
2221
|
Flags2.FlagsEvaluationErrorCode = FlagsEvaluationErrorCode;
|
|
1652
2222
|
Flags2.FlagsEvaluationReason = FlagsEvaluationReason;
|
|
1653
2223
|
Flags2.FlagsEvaluationWarningCode = FlagsEvaluationWarningCode;
|
|
2224
|
+
Flags2.FlagsGovernanceActorType = FlagsGovernanceActorType;
|
|
1654
2225
|
Flags2.FlagsHistoryExportFormat = FlagsHistoryExportFormat;
|
|
1655
2226
|
Flags2.FlagsImportMappedType = FlagsImportMappedType;
|
|
1656
2227
|
Flags2.FlagsImportSource = FlagsImportSource;
|
|
1657
2228
|
Flags2.FlagsJsonPatchOp = FlagsJsonPatchOp;
|
|
1658
2229
|
Flags2.FlagsPrerequisiteComparator = FlagsPrerequisiteComparator;
|
|
2230
|
+
Flags2.FlagsRampStatus = FlagsRampStatus;
|
|
2231
|
+
Flags2.FlagsReviewDecision = FlagsReviewDecision;
|
|
2232
|
+
Flags2.FlagsScheduledChangeStatus = FlagsScheduledChangeStatus;
|
|
2233
|
+
Flags2.FlagsScheduledOperation = FlagsScheduledOperation;
|
|
1659
2234
|
Flags2.FlagsSdkKeyRotationReason = FlagsSdkKeyRotationReason;
|
|
1660
2235
|
Flags2.FlagsSdkKeySlot = FlagsSdkKeySlot;
|
|
1661
2236
|
Flags2.FlagsSegmentComparator = FlagsSegmentComparator;
|
|
1662
2237
|
Flags2.FlagsSettingLifecycle = FlagsSettingLifecycle;
|
|
1663
2238
|
Flags2.FlagsSettingType = FlagsSettingType;
|
|
2239
|
+
Flags2.FlagsStaleReason = FlagsStaleReason;
|
|
1664
2240
|
Flags2.FlagsUserComparator = FlagsUserComparator;
|
|
1665
2241
|
Flags2.FlagsWebhookActorType = FlagsWebhookActorType;
|
|
1666
2242
|
Flags2.SdkKeySlot = SdkKeySlot;
|
|
@@ -1672,5 +2248,5 @@ var Flags = class extends FlagsResources {
|
|
|
1672
2248
|
})(Flags || (Flags = {}));
|
|
1673
2249
|
|
|
1674
2250
|
export { Flags };
|
|
1675
|
-
//# sourceMappingURL=chunk-
|
|
1676
|
-
//# sourceMappingURL=chunk-
|
|
2251
|
+
//# sourceMappingURL=chunk-JGSMXA3G.js.map
|
|
2252
|
+
//# sourceMappingURL=chunk-JGSMXA3G.js.map
|