@ship-cli/core 0.1.9 → 0.1.10
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 +11 -1
- package/dist/bin.js +2416 -28
- package/package.json +2 -1
package/dist/bin.js
CHANGED
|
@@ -8208,6 +8208,1469 @@ var require_printer = __commonJS({
|
|
|
8208
8208
|
}
|
|
8209
8209
|
});
|
|
8210
8210
|
|
|
8211
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/utils.js
|
|
8212
|
+
var require_utils = __commonJS({
|
|
8213
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/utils.js"(exports$1) {
|
|
8214
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
8215
|
+
exports$1.assertNever = assertNever;
|
|
8216
|
+
exports$1.pick = pick4;
|
|
8217
|
+
exports$1.isObject = isObject2;
|
|
8218
|
+
function assertNever(value5) {
|
|
8219
|
+
throw new Error(`Unexpected value should never occur: ${value5}`);
|
|
8220
|
+
}
|
|
8221
|
+
function pick4(base, keys6) {
|
|
8222
|
+
const entries2 = keys6.map((key) => [key, base === null || base === void 0 ? void 0 : base[key]]);
|
|
8223
|
+
return Object.fromEntries(entries2);
|
|
8224
|
+
}
|
|
8225
|
+
function isObject2(o2) {
|
|
8226
|
+
return typeof o2 === "object" && o2 !== null;
|
|
8227
|
+
}
|
|
8228
|
+
}
|
|
8229
|
+
});
|
|
8230
|
+
|
|
8231
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/logging.js
|
|
8232
|
+
var require_logging = __commonJS({
|
|
8233
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/logging.js"(exports$1) {
|
|
8234
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
8235
|
+
exports$1.LogLevel = void 0;
|
|
8236
|
+
exports$1.makeConsoleLogger = makeConsoleLogger;
|
|
8237
|
+
exports$1.logLevelSeverity = logLevelSeverity;
|
|
8238
|
+
var utils_1 = require_utils();
|
|
8239
|
+
var LogLevel;
|
|
8240
|
+
(function(LogLevel2) {
|
|
8241
|
+
LogLevel2["DEBUG"] = "debug";
|
|
8242
|
+
LogLevel2["INFO"] = "info";
|
|
8243
|
+
LogLevel2["WARN"] = "warn";
|
|
8244
|
+
LogLevel2["ERROR"] = "error";
|
|
8245
|
+
})(LogLevel || (exports$1.LogLevel = LogLevel = {}));
|
|
8246
|
+
function makeConsoleLogger(name) {
|
|
8247
|
+
return (level, message, extraInfo) => {
|
|
8248
|
+
console[level](`${name} ${level}:`, message, extraInfo);
|
|
8249
|
+
};
|
|
8250
|
+
}
|
|
8251
|
+
function logLevelSeverity(level) {
|
|
8252
|
+
switch (level) {
|
|
8253
|
+
case LogLevel.DEBUG:
|
|
8254
|
+
return 20;
|
|
8255
|
+
case LogLevel.INFO:
|
|
8256
|
+
return 40;
|
|
8257
|
+
case LogLevel.WARN:
|
|
8258
|
+
return 60;
|
|
8259
|
+
case LogLevel.ERROR:
|
|
8260
|
+
return 80;
|
|
8261
|
+
default:
|
|
8262
|
+
return (0, utils_1.assertNever)(level);
|
|
8263
|
+
}
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
});
|
|
8267
|
+
|
|
8268
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/errors.js
|
|
8269
|
+
var require_errors2 = __commonJS({
|
|
8270
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/errors.js"(exports$1) {
|
|
8271
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
8272
|
+
exports$1.APIResponseError = exports$1.UnknownHTTPResponseError = exports$1.RequestTimeoutError = exports$1.ClientErrorCode = exports$1.APIErrorCode = void 0;
|
|
8273
|
+
exports$1.isNotionClientError = isNotionClientError2;
|
|
8274
|
+
exports$1.isHTTPResponseError = isHTTPResponseError;
|
|
8275
|
+
exports$1.buildRequestError = buildRequestError;
|
|
8276
|
+
var utils_1 = require_utils();
|
|
8277
|
+
var APIErrorCode2;
|
|
8278
|
+
(function(APIErrorCode3) {
|
|
8279
|
+
APIErrorCode3["Unauthorized"] = "unauthorized";
|
|
8280
|
+
APIErrorCode3["RestrictedResource"] = "restricted_resource";
|
|
8281
|
+
APIErrorCode3["ObjectNotFound"] = "object_not_found";
|
|
8282
|
+
APIErrorCode3["RateLimited"] = "rate_limited";
|
|
8283
|
+
APIErrorCode3["InvalidJSON"] = "invalid_json";
|
|
8284
|
+
APIErrorCode3["InvalidRequestURL"] = "invalid_request_url";
|
|
8285
|
+
APIErrorCode3["InvalidRequest"] = "invalid_request";
|
|
8286
|
+
APIErrorCode3["ValidationError"] = "validation_error";
|
|
8287
|
+
APIErrorCode3["ConflictError"] = "conflict_error";
|
|
8288
|
+
APIErrorCode3["InternalServerError"] = "internal_server_error";
|
|
8289
|
+
APIErrorCode3["ServiceUnavailable"] = "service_unavailable";
|
|
8290
|
+
})(APIErrorCode2 || (exports$1.APIErrorCode = APIErrorCode2 = {}));
|
|
8291
|
+
var ClientErrorCode;
|
|
8292
|
+
(function(ClientErrorCode2) {
|
|
8293
|
+
ClientErrorCode2["RequestTimeout"] = "notionhq_client_request_timeout";
|
|
8294
|
+
ClientErrorCode2["ResponseError"] = "notionhq_client_response_error";
|
|
8295
|
+
})(ClientErrorCode || (exports$1.ClientErrorCode = ClientErrorCode = {}));
|
|
8296
|
+
var NotionClientErrorBase = class extends Error {
|
|
8297
|
+
};
|
|
8298
|
+
function isNotionClientError2(error4) {
|
|
8299
|
+
return (0, utils_1.isObject)(error4) && error4 instanceof NotionClientErrorBase;
|
|
8300
|
+
}
|
|
8301
|
+
function isNotionClientErrorWithCode(error4, codes) {
|
|
8302
|
+
return isNotionClientError2(error4) && error4.code in codes;
|
|
8303
|
+
}
|
|
8304
|
+
var RequestTimeoutError = class _RequestTimeoutError extends NotionClientErrorBase {
|
|
8305
|
+
constructor(message = "Request to Notion API has timed out") {
|
|
8306
|
+
super(message);
|
|
8307
|
+
this.code = ClientErrorCode.RequestTimeout;
|
|
8308
|
+
this.name = "RequestTimeoutError";
|
|
8309
|
+
}
|
|
8310
|
+
static isRequestTimeoutError(error4) {
|
|
8311
|
+
return isNotionClientErrorWithCode(error4, {
|
|
8312
|
+
[ClientErrorCode.RequestTimeout]: true
|
|
8313
|
+
});
|
|
8314
|
+
}
|
|
8315
|
+
static rejectAfterTimeout(promise3, timeoutMS) {
|
|
8316
|
+
return new Promise((resolve3, reject) => {
|
|
8317
|
+
const timeoutId = setTimeout(() => {
|
|
8318
|
+
reject(new _RequestTimeoutError());
|
|
8319
|
+
}, timeoutMS);
|
|
8320
|
+
promise3.then(resolve3).catch(reject).then(() => clearTimeout(timeoutId));
|
|
8321
|
+
});
|
|
8322
|
+
}
|
|
8323
|
+
};
|
|
8324
|
+
exports$1.RequestTimeoutError = RequestTimeoutError;
|
|
8325
|
+
var HTTPResponseError = class extends NotionClientErrorBase {
|
|
8326
|
+
constructor(args2) {
|
|
8327
|
+
super(args2.message);
|
|
8328
|
+
this.name = "HTTPResponseError";
|
|
8329
|
+
const { code: code2, status: status2, headers, rawBodyText, additional_data, request_id } = args2;
|
|
8330
|
+
this.code = code2;
|
|
8331
|
+
this.status = status2;
|
|
8332
|
+
this.headers = headers;
|
|
8333
|
+
this.body = rawBodyText;
|
|
8334
|
+
this.additional_data = additional_data;
|
|
8335
|
+
this.request_id = request_id;
|
|
8336
|
+
}
|
|
8337
|
+
};
|
|
8338
|
+
var httpResponseErrorCodes = {
|
|
8339
|
+
[ClientErrorCode.ResponseError]: true,
|
|
8340
|
+
[APIErrorCode2.Unauthorized]: true,
|
|
8341
|
+
[APIErrorCode2.RestrictedResource]: true,
|
|
8342
|
+
[APIErrorCode2.ObjectNotFound]: true,
|
|
8343
|
+
[APIErrorCode2.RateLimited]: true,
|
|
8344
|
+
[APIErrorCode2.InvalidJSON]: true,
|
|
8345
|
+
[APIErrorCode2.InvalidRequestURL]: true,
|
|
8346
|
+
[APIErrorCode2.InvalidRequest]: true,
|
|
8347
|
+
[APIErrorCode2.ValidationError]: true,
|
|
8348
|
+
[APIErrorCode2.ConflictError]: true,
|
|
8349
|
+
[APIErrorCode2.InternalServerError]: true,
|
|
8350
|
+
[APIErrorCode2.ServiceUnavailable]: true
|
|
8351
|
+
};
|
|
8352
|
+
function isHTTPResponseError(error4) {
|
|
8353
|
+
if (!isNotionClientErrorWithCode(error4, httpResponseErrorCodes)) {
|
|
8354
|
+
return false;
|
|
8355
|
+
}
|
|
8356
|
+
return true;
|
|
8357
|
+
}
|
|
8358
|
+
var UnknownHTTPResponseError = class extends HTTPResponseError {
|
|
8359
|
+
constructor(args2) {
|
|
8360
|
+
var _a;
|
|
8361
|
+
super({
|
|
8362
|
+
...args2,
|
|
8363
|
+
code: ClientErrorCode.ResponseError,
|
|
8364
|
+
message: (_a = args2.message) !== null && _a !== void 0 ? _a : `Request to Notion API failed with status: ${args2.status}`,
|
|
8365
|
+
additional_data: void 0,
|
|
8366
|
+
request_id: void 0
|
|
8367
|
+
});
|
|
8368
|
+
this.name = "UnknownHTTPResponseError";
|
|
8369
|
+
}
|
|
8370
|
+
static isUnknownHTTPResponseError(error4) {
|
|
8371
|
+
return isNotionClientErrorWithCode(error4, {
|
|
8372
|
+
[ClientErrorCode.ResponseError]: true
|
|
8373
|
+
});
|
|
8374
|
+
}
|
|
8375
|
+
};
|
|
8376
|
+
exports$1.UnknownHTTPResponseError = UnknownHTTPResponseError;
|
|
8377
|
+
var apiErrorCodes = {
|
|
8378
|
+
[APIErrorCode2.Unauthorized]: true,
|
|
8379
|
+
[APIErrorCode2.RestrictedResource]: true,
|
|
8380
|
+
[APIErrorCode2.ObjectNotFound]: true,
|
|
8381
|
+
[APIErrorCode2.RateLimited]: true,
|
|
8382
|
+
[APIErrorCode2.InvalidJSON]: true,
|
|
8383
|
+
[APIErrorCode2.InvalidRequestURL]: true,
|
|
8384
|
+
[APIErrorCode2.InvalidRequest]: true,
|
|
8385
|
+
[APIErrorCode2.ValidationError]: true,
|
|
8386
|
+
[APIErrorCode2.ConflictError]: true,
|
|
8387
|
+
[APIErrorCode2.InternalServerError]: true,
|
|
8388
|
+
[APIErrorCode2.ServiceUnavailable]: true
|
|
8389
|
+
};
|
|
8390
|
+
var APIResponseError = class extends HTTPResponseError {
|
|
8391
|
+
constructor() {
|
|
8392
|
+
super(...arguments);
|
|
8393
|
+
this.name = "APIResponseError";
|
|
8394
|
+
}
|
|
8395
|
+
static isAPIResponseError(error4) {
|
|
8396
|
+
return isNotionClientErrorWithCode(error4, apiErrorCodes);
|
|
8397
|
+
}
|
|
8398
|
+
};
|
|
8399
|
+
exports$1.APIResponseError = APIResponseError;
|
|
8400
|
+
function buildRequestError(response, bodyText2) {
|
|
8401
|
+
const apiErrorResponseBody = parseAPIErrorResponseBody(bodyText2);
|
|
8402
|
+
if (apiErrorResponseBody !== void 0) {
|
|
8403
|
+
return new APIResponseError({
|
|
8404
|
+
code: apiErrorResponseBody.code,
|
|
8405
|
+
message: apiErrorResponseBody.message,
|
|
8406
|
+
headers: response.headers,
|
|
8407
|
+
status: response.status,
|
|
8408
|
+
rawBodyText: bodyText2,
|
|
8409
|
+
additional_data: apiErrorResponseBody.additional_data,
|
|
8410
|
+
request_id: apiErrorResponseBody.request_id
|
|
8411
|
+
});
|
|
8412
|
+
}
|
|
8413
|
+
return new UnknownHTTPResponseError({
|
|
8414
|
+
message: void 0,
|
|
8415
|
+
headers: response.headers,
|
|
8416
|
+
status: response.status,
|
|
8417
|
+
rawBodyText: bodyText2
|
|
8418
|
+
});
|
|
8419
|
+
}
|
|
8420
|
+
function parseAPIErrorResponseBody(body) {
|
|
8421
|
+
if (typeof body !== "string") {
|
|
8422
|
+
return;
|
|
8423
|
+
}
|
|
8424
|
+
let parsed;
|
|
8425
|
+
try {
|
|
8426
|
+
parsed = JSON.parse(body);
|
|
8427
|
+
} catch (parseError2) {
|
|
8428
|
+
return;
|
|
8429
|
+
}
|
|
8430
|
+
if (!(0, utils_1.isObject)(parsed) || typeof parsed["message"] !== "string" || !isAPIErrorCode(parsed["code"])) {
|
|
8431
|
+
return;
|
|
8432
|
+
}
|
|
8433
|
+
const additional_data = parsed["additional_data"];
|
|
8434
|
+
const request_id = parsed["request_id"];
|
|
8435
|
+
return {
|
|
8436
|
+
...parsed,
|
|
8437
|
+
code: parsed["code"],
|
|
8438
|
+
message: parsed["message"],
|
|
8439
|
+
additional_data,
|
|
8440
|
+
request_id
|
|
8441
|
+
};
|
|
8442
|
+
}
|
|
8443
|
+
function isAPIErrorCode(code2) {
|
|
8444
|
+
return typeof code2 === "string" && code2 in apiErrorCodes;
|
|
8445
|
+
}
|
|
8446
|
+
}
|
|
8447
|
+
});
|
|
8448
|
+
|
|
8449
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/api-endpoints.js
|
|
8450
|
+
var require_api_endpoints = __commonJS({
|
|
8451
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/api-endpoints.js"(exports$1) {
|
|
8452
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
8453
|
+
exports$1.movePage = exports$1.oauthIntrospect = exports$1.oauthRevoke = exports$1.oauthToken = exports$1.getFileUpload = exports$1.completeFileUpload = exports$1.sendFileUpload = exports$1.listFileUploads = exports$1.createFileUpload = exports$1.getComment = exports$1.listComments = exports$1.createComment = exports$1.search = exports$1.createDatabase = exports$1.updateDatabase = exports$1.getDatabase = exports$1.listDataSourceTemplates = exports$1.createDataSource = exports$1.queryDataSource = exports$1.updateDataSource = exports$1.getDataSource = exports$1.appendBlockChildren = exports$1.listBlockChildren = exports$1.deleteBlock = exports$1.updateBlock = exports$1.getBlock = exports$1.getPageProperty = exports$1.updatePage = exports$1.getPage = exports$1.createPage = exports$1.listUsers = exports$1.getUser = exports$1.getSelf = void 0;
|
|
8454
|
+
exports$1.getSelf = {
|
|
8455
|
+
method: "get",
|
|
8456
|
+
pathParams: [],
|
|
8457
|
+
queryParams: [],
|
|
8458
|
+
bodyParams: [],
|
|
8459
|
+
path: () => `users/me`
|
|
8460
|
+
};
|
|
8461
|
+
exports$1.getUser = {
|
|
8462
|
+
method: "get",
|
|
8463
|
+
pathParams: ["user_id"],
|
|
8464
|
+
queryParams: [],
|
|
8465
|
+
bodyParams: [],
|
|
8466
|
+
path: (p4) => `users/${p4.user_id}`
|
|
8467
|
+
};
|
|
8468
|
+
exports$1.listUsers = {
|
|
8469
|
+
method: "get",
|
|
8470
|
+
pathParams: [],
|
|
8471
|
+
queryParams: ["start_cursor", "page_size"],
|
|
8472
|
+
bodyParams: [],
|
|
8473
|
+
path: () => `users`
|
|
8474
|
+
};
|
|
8475
|
+
exports$1.createPage = {
|
|
8476
|
+
method: "post",
|
|
8477
|
+
pathParams: [],
|
|
8478
|
+
queryParams: [],
|
|
8479
|
+
bodyParams: [
|
|
8480
|
+
"parent",
|
|
8481
|
+
"properties",
|
|
8482
|
+
"icon",
|
|
8483
|
+
"cover",
|
|
8484
|
+
"content",
|
|
8485
|
+
"children",
|
|
8486
|
+
"template"
|
|
8487
|
+
],
|
|
8488
|
+
path: () => `pages`
|
|
8489
|
+
};
|
|
8490
|
+
exports$1.getPage = {
|
|
8491
|
+
method: "get",
|
|
8492
|
+
pathParams: ["page_id"],
|
|
8493
|
+
queryParams: ["filter_properties"],
|
|
8494
|
+
bodyParams: [],
|
|
8495
|
+
path: (p4) => `pages/${p4.page_id}`
|
|
8496
|
+
};
|
|
8497
|
+
exports$1.updatePage = {
|
|
8498
|
+
method: "patch",
|
|
8499
|
+
pathParams: ["page_id"],
|
|
8500
|
+
queryParams: [],
|
|
8501
|
+
bodyParams: [
|
|
8502
|
+
"properties",
|
|
8503
|
+
"icon",
|
|
8504
|
+
"cover",
|
|
8505
|
+
"is_locked",
|
|
8506
|
+
"template",
|
|
8507
|
+
"erase_content",
|
|
8508
|
+
"archived",
|
|
8509
|
+
"in_trash"
|
|
8510
|
+
],
|
|
8511
|
+
path: (p4) => `pages/${p4.page_id}`
|
|
8512
|
+
};
|
|
8513
|
+
exports$1.getPageProperty = {
|
|
8514
|
+
method: "get",
|
|
8515
|
+
pathParams: ["page_id", "property_id"],
|
|
8516
|
+
queryParams: ["start_cursor", "page_size"],
|
|
8517
|
+
bodyParams: [],
|
|
8518
|
+
path: (p4) => `pages/${p4.page_id}/properties/${p4.property_id}`
|
|
8519
|
+
};
|
|
8520
|
+
exports$1.getBlock = {
|
|
8521
|
+
method: "get",
|
|
8522
|
+
pathParams: ["block_id"],
|
|
8523
|
+
queryParams: [],
|
|
8524
|
+
bodyParams: [],
|
|
8525
|
+
path: (p4) => `blocks/${p4.block_id}`
|
|
8526
|
+
};
|
|
8527
|
+
exports$1.updateBlock = {
|
|
8528
|
+
method: "patch",
|
|
8529
|
+
pathParams: ["block_id"],
|
|
8530
|
+
queryParams: [],
|
|
8531
|
+
bodyParams: [
|
|
8532
|
+
"embed",
|
|
8533
|
+
"type",
|
|
8534
|
+
"archived",
|
|
8535
|
+
"in_trash",
|
|
8536
|
+
"bookmark",
|
|
8537
|
+
"image",
|
|
8538
|
+
"video",
|
|
8539
|
+
"pdf",
|
|
8540
|
+
"file",
|
|
8541
|
+
"audio",
|
|
8542
|
+
"code",
|
|
8543
|
+
"equation",
|
|
8544
|
+
"divider",
|
|
8545
|
+
"breadcrumb",
|
|
8546
|
+
"table_of_contents",
|
|
8547
|
+
"link_to_page",
|
|
8548
|
+
"table_row",
|
|
8549
|
+
"heading_1",
|
|
8550
|
+
"heading_2",
|
|
8551
|
+
"heading_3",
|
|
8552
|
+
"paragraph",
|
|
8553
|
+
"bulleted_list_item",
|
|
8554
|
+
"numbered_list_item",
|
|
8555
|
+
"quote",
|
|
8556
|
+
"to_do",
|
|
8557
|
+
"toggle",
|
|
8558
|
+
"template",
|
|
8559
|
+
"callout",
|
|
8560
|
+
"synced_block",
|
|
8561
|
+
"table",
|
|
8562
|
+
"column"
|
|
8563
|
+
],
|
|
8564
|
+
path: (p4) => `blocks/${p4.block_id}`
|
|
8565
|
+
};
|
|
8566
|
+
exports$1.deleteBlock = {
|
|
8567
|
+
method: "delete",
|
|
8568
|
+
pathParams: ["block_id"],
|
|
8569
|
+
queryParams: [],
|
|
8570
|
+
bodyParams: [],
|
|
8571
|
+
path: (p4) => `blocks/${p4.block_id}`
|
|
8572
|
+
};
|
|
8573
|
+
exports$1.listBlockChildren = {
|
|
8574
|
+
method: "get",
|
|
8575
|
+
pathParams: ["block_id"],
|
|
8576
|
+
queryParams: ["start_cursor", "page_size"],
|
|
8577
|
+
bodyParams: [],
|
|
8578
|
+
path: (p4) => `blocks/${p4.block_id}/children`
|
|
8579
|
+
};
|
|
8580
|
+
exports$1.appendBlockChildren = {
|
|
8581
|
+
method: "patch",
|
|
8582
|
+
pathParams: ["block_id"],
|
|
8583
|
+
queryParams: [],
|
|
8584
|
+
bodyParams: ["children", "after"],
|
|
8585
|
+
path: (p4) => `blocks/${p4.block_id}/children`
|
|
8586
|
+
};
|
|
8587
|
+
exports$1.getDataSource = {
|
|
8588
|
+
method: "get",
|
|
8589
|
+
pathParams: ["data_source_id"],
|
|
8590
|
+
queryParams: [],
|
|
8591
|
+
bodyParams: [],
|
|
8592
|
+
path: (p4) => `data_sources/${p4.data_source_id}`
|
|
8593
|
+
};
|
|
8594
|
+
exports$1.updateDataSource = {
|
|
8595
|
+
method: "patch",
|
|
8596
|
+
pathParams: ["data_source_id"],
|
|
8597
|
+
queryParams: [],
|
|
8598
|
+
bodyParams: ["title", "icon", "properties", "in_trash", "archived", "parent"],
|
|
8599
|
+
path: (p4) => `data_sources/${p4.data_source_id}`
|
|
8600
|
+
};
|
|
8601
|
+
exports$1.queryDataSource = {
|
|
8602
|
+
method: "post",
|
|
8603
|
+
pathParams: ["data_source_id"],
|
|
8604
|
+
queryParams: ["filter_properties"],
|
|
8605
|
+
bodyParams: [
|
|
8606
|
+
"sorts",
|
|
8607
|
+
"filter",
|
|
8608
|
+
"start_cursor",
|
|
8609
|
+
"page_size",
|
|
8610
|
+
"archived",
|
|
8611
|
+
"in_trash",
|
|
8612
|
+
"result_type"
|
|
8613
|
+
],
|
|
8614
|
+
path: (p4) => `data_sources/${p4.data_source_id}/query`
|
|
8615
|
+
};
|
|
8616
|
+
exports$1.createDataSource = {
|
|
8617
|
+
method: "post",
|
|
8618
|
+
pathParams: [],
|
|
8619
|
+
queryParams: [],
|
|
8620
|
+
bodyParams: ["parent", "properties", "title", "icon"],
|
|
8621
|
+
path: () => `data_sources`
|
|
8622
|
+
};
|
|
8623
|
+
exports$1.listDataSourceTemplates = {
|
|
8624
|
+
method: "get",
|
|
8625
|
+
pathParams: ["data_source_id"],
|
|
8626
|
+
queryParams: ["name", "start_cursor", "page_size"],
|
|
8627
|
+
bodyParams: [],
|
|
8628
|
+
path: (p4) => `data_sources/${p4.data_source_id}/templates`
|
|
8629
|
+
};
|
|
8630
|
+
exports$1.getDatabase = {
|
|
8631
|
+
method: "get",
|
|
8632
|
+
pathParams: ["database_id"],
|
|
8633
|
+
queryParams: [],
|
|
8634
|
+
bodyParams: [],
|
|
8635
|
+
path: (p4) => `databases/${p4.database_id}`
|
|
8636
|
+
};
|
|
8637
|
+
exports$1.updateDatabase = {
|
|
8638
|
+
method: "patch",
|
|
8639
|
+
pathParams: ["database_id"],
|
|
8640
|
+
queryParams: [],
|
|
8641
|
+
bodyParams: [
|
|
8642
|
+
"parent",
|
|
8643
|
+
"title",
|
|
8644
|
+
"description",
|
|
8645
|
+
"is_inline",
|
|
8646
|
+
"icon",
|
|
8647
|
+
"cover",
|
|
8648
|
+
"in_trash",
|
|
8649
|
+
"is_locked"
|
|
8650
|
+
],
|
|
8651
|
+
path: (p4) => `databases/${p4.database_id}`
|
|
8652
|
+
};
|
|
8653
|
+
exports$1.createDatabase = {
|
|
8654
|
+
method: "post",
|
|
8655
|
+
pathParams: [],
|
|
8656
|
+
queryParams: [],
|
|
8657
|
+
bodyParams: [
|
|
8658
|
+
"parent",
|
|
8659
|
+
"title",
|
|
8660
|
+
"description",
|
|
8661
|
+
"is_inline",
|
|
8662
|
+
"initial_data_source",
|
|
8663
|
+
"icon",
|
|
8664
|
+
"cover"
|
|
8665
|
+
],
|
|
8666
|
+
path: () => `databases`
|
|
8667
|
+
};
|
|
8668
|
+
exports$1.search = {
|
|
8669
|
+
method: "post",
|
|
8670
|
+
pathParams: [],
|
|
8671
|
+
queryParams: [],
|
|
8672
|
+
bodyParams: ["sort", "query", "start_cursor", "page_size", "filter"],
|
|
8673
|
+
path: () => `search`
|
|
8674
|
+
};
|
|
8675
|
+
exports$1.createComment = {
|
|
8676
|
+
method: "post",
|
|
8677
|
+
pathParams: [],
|
|
8678
|
+
queryParams: [],
|
|
8679
|
+
bodyParams: [
|
|
8680
|
+
"rich_text",
|
|
8681
|
+
"attachments",
|
|
8682
|
+
"display_name",
|
|
8683
|
+
"parent",
|
|
8684
|
+
"discussion_id"
|
|
8685
|
+
],
|
|
8686
|
+
path: () => `comments`
|
|
8687
|
+
};
|
|
8688
|
+
exports$1.listComments = {
|
|
8689
|
+
method: "get",
|
|
8690
|
+
pathParams: [],
|
|
8691
|
+
queryParams: ["block_id", "start_cursor", "page_size"],
|
|
8692
|
+
bodyParams: [],
|
|
8693
|
+
path: () => `comments`
|
|
8694
|
+
};
|
|
8695
|
+
exports$1.getComment = {
|
|
8696
|
+
method: "get",
|
|
8697
|
+
pathParams: ["comment_id"],
|
|
8698
|
+
queryParams: [],
|
|
8699
|
+
bodyParams: [],
|
|
8700
|
+
path: (p4) => `comments/${p4.comment_id}`
|
|
8701
|
+
};
|
|
8702
|
+
exports$1.createFileUpload = {
|
|
8703
|
+
method: "post",
|
|
8704
|
+
pathParams: [],
|
|
8705
|
+
queryParams: [],
|
|
8706
|
+
bodyParams: [
|
|
8707
|
+
"mode",
|
|
8708
|
+
"filename",
|
|
8709
|
+
"content_type",
|
|
8710
|
+
"number_of_parts",
|
|
8711
|
+
"external_url"
|
|
8712
|
+
],
|
|
8713
|
+
path: () => `file_uploads`
|
|
8714
|
+
};
|
|
8715
|
+
exports$1.listFileUploads = {
|
|
8716
|
+
method: "get",
|
|
8717
|
+
pathParams: [],
|
|
8718
|
+
queryParams: ["status", "start_cursor", "page_size"],
|
|
8719
|
+
bodyParams: [],
|
|
8720
|
+
path: () => `file_uploads`
|
|
8721
|
+
};
|
|
8722
|
+
exports$1.sendFileUpload = {
|
|
8723
|
+
method: "post",
|
|
8724
|
+
pathParams: ["file_upload_id"],
|
|
8725
|
+
queryParams: [],
|
|
8726
|
+
bodyParams: [],
|
|
8727
|
+
formDataParams: ["file", "part_number"],
|
|
8728
|
+
path: (p4) => `file_uploads/${p4.file_upload_id}/send`
|
|
8729
|
+
};
|
|
8730
|
+
exports$1.completeFileUpload = {
|
|
8731
|
+
method: "post",
|
|
8732
|
+
pathParams: ["file_upload_id"],
|
|
8733
|
+
queryParams: [],
|
|
8734
|
+
bodyParams: [],
|
|
8735
|
+
path: (p4) => `file_uploads/${p4.file_upload_id}/complete`
|
|
8736
|
+
};
|
|
8737
|
+
exports$1.getFileUpload = {
|
|
8738
|
+
method: "get",
|
|
8739
|
+
pathParams: ["file_upload_id"],
|
|
8740
|
+
queryParams: [],
|
|
8741
|
+
bodyParams: [],
|
|
8742
|
+
path: (p4) => `file_uploads/${p4.file_upload_id}`
|
|
8743
|
+
};
|
|
8744
|
+
exports$1.oauthToken = {
|
|
8745
|
+
method: "post",
|
|
8746
|
+
pathParams: [],
|
|
8747
|
+
queryParams: [],
|
|
8748
|
+
bodyParams: [
|
|
8749
|
+
"grant_type",
|
|
8750
|
+
"code",
|
|
8751
|
+
"redirect_uri",
|
|
8752
|
+
"external_account",
|
|
8753
|
+
"refresh_token"
|
|
8754
|
+
],
|
|
8755
|
+
path: () => `oauth/token`
|
|
8756
|
+
};
|
|
8757
|
+
exports$1.oauthRevoke = {
|
|
8758
|
+
method: "post",
|
|
8759
|
+
pathParams: [],
|
|
8760
|
+
queryParams: [],
|
|
8761
|
+
bodyParams: ["token"],
|
|
8762
|
+
path: () => `oauth/revoke`
|
|
8763
|
+
};
|
|
8764
|
+
exports$1.oauthIntrospect = {
|
|
8765
|
+
method: "post",
|
|
8766
|
+
pathParams: [],
|
|
8767
|
+
queryParams: [],
|
|
8768
|
+
bodyParams: ["token"],
|
|
8769
|
+
path: () => `oauth/introspect`
|
|
8770
|
+
};
|
|
8771
|
+
exports$1.movePage = {
|
|
8772
|
+
method: "post",
|
|
8773
|
+
pathParams: ["page_id"],
|
|
8774
|
+
queryParams: [],
|
|
8775
|
+
bodyParams: ["parent"],
|
|
8776
|
+
path: (p4) => `pages/${p4.page_id}/move`
|
|
8777
|
+
};
|
|
8778
|
+
}
|
|
8779
|
+
});
|
|
8780
|
+
|
|
8781
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/package.json
|
|
8782
|
+
var require_package = __commonJS({
|
|
8783
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/package.json"(exports$1, module) {
|
|
8784
|
+
module.exports = {
|
|
8785
|
+
name: "@notionhq/client",
|
|
8786
|
+
version: "5.6.0",
|
|
8787
|
+
description: "A simple and easy to use client for the Notion API",
|
|
8788
|
+
engines: {
|
|
8789
|
+
node: ">=18"
|
|
8790
|
+
},
|
|
8791
|
+
homepage: "https://developers.notion.com/docs/getting-started",
|
|
8792
|
+
bugs: {
|
|
8793
|
+
url: "https://github.com/makenotion/notion-sdk-js/issues"
|
|
8794
|
+
},
|
|
8795
|
+
repository: {
|
|
8796
|
+
type: "git",
|
|
8797
|
+
url: "https://github.com/makenotion/notion-sdk-js/"
|
|
8798
|
+
},
|
|
8799
|
+
keywords: [
|
|
8800
|
+
"notion",
|
|
8801
|
+
"notionapi",
|
|
8802
|
+
"rest",
|
|
8803
|
+
"notion-api"
|
|
8804
|
+
],
|
|
8805
|
+
main: "./build/src",
|
|
8806
|
+
types: "./build/src/index.d.ts",
|
|
8807
|
+
scripts: {
|
|
8808
|
+
prepare: "husky && npm run build",
|
|
8809
|
+
prepublishOnly: "npm run checkLoggedIn && npm run lint && npm run test",
|
|
8810
|
+
build: "tsc",
|
|
8811
|
+
prettier: "prettier --write .",
|
|
8812
|
+
lint: "prettier --check . && eslint . --ext .ts && cspell '**/*' ",
|
|
8813
|
+
test: "jest ./test",
|
|
8814
|
+
"check-links": "git ls-files | grep md$ | xargs -n 1 markdown-link-check",
|
|
8815
|
+
prebuild: "npm run clean",
|
|
8816
|
+
clean: "rm -rf ./build",
|
|
8817
|
+
checkLoggedIn: "./scripts/verifyLoggedIn.sh"
|
|
8818
|
+
},
|
|
8819
|
+
"lint-staged": {
|
|
8820
|
+
"*.{ts,js,json,md}": "prettier --write",
|
|
8821
|
+
"*.ts": "eslint --fix"
|
|
8822
|
+
},
|
|
8823
|
+
author: "",
|
|
8824
|
+
license: "MIT",
|
|
8825
|
+
files: [
|
|
8826
|
+
"build/package.json",
|
|
8827
|
+
"build/src/**"
|
|
8828
|
+
],
|
|
8829
|
+
devDependencies: {
|
|
8830
|
+
"@types/jest": "28.1.4",
|
|
8831
|
+
"@typescript-eslint/eslint-plugin": "5.39.0",
|
|
8832
|
+
"@typescript-eslint/parser": "5.39.0",
|
|
8833
|
+
cspell: "5.4.1",
|
|
8834
|
+
eslint: "7.24.0",
|
|
8835
|
+
husky: "^9.1.7",
|
|
8836
|
+
jest: "28.1.2",
|
|
8837
|
+
"lint-staged": "^16.2.6",
|
|
8838
|
+
"markdown-link-check": "3.13.7",
|
|
8839
|
+
prettier: "2.8.8",
|
|
8840
|
+
"ts-jest": "28.0.5",
|
|
8841
|
+
typescript: "5.9.2"
|
|
8842
|
+
}
|
|
8843
|
+
};
|
|
8844
|
+
}
|
|
8845
|
+
});
|
|
8846
|
+
|
|
8847
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/Client.js
|
|
8848
|
+
var require_Client = __commonJS({
|
|
8849
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/Client.js"(exports$1) {
|
|
8850
|
+
var __classPrivateFieldSet = exports$1 && exports$1.__classPrivateFieldSet || function(receiver, state, value5, kind, f) {
|
|
8851
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8852
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
8853
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
8854
|
+
return kind === "a" ? f.call(receiver, value5) : f ? f.value = value5 : state.set(receiver, value5), value5;
|
|
8855
|
+
};
|
|
8856
|
+
var __classPrivateFieldGet = exports$1 && exports$1.__classPrivateFieldGet || function(receiver, state, kind, f) {
|
|
8857
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
8858
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
8859
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
8860
|
+
};
|
|
8861
|
+
var _Client_auth;
|
|
8862
|
+
var _Client_logLevel;
|
|
8863
|
+
var _Client_logger;
|
|
8864
|
+
var _Client_prefixUrl;
|
|
8865
|
+
var _Client_timeoutMs;
|
|
8866
|
+
var _Client_notionVersion;
|
|
8867
|
+
var _Client_fetch;
|
|
8868
|
+
var _Client_agent;
|
|
8869
|
+
var _Client_userAgent;
|
|
8870
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
8871
|
+
var logging_1 = require_logging();
|
|
8872
|
+
var errors_1 = require_errors2();
|
|
8873
|
+
var utils_1 = require_utils();
|
|
8874
|
+
var api_endpoints_1 = require_api_endpoints();
|
|
8875
|
+
var package_json_1 = require_package();
|
|
8876
|
+
var Client = class _Client {
|
|
8877
|
+
constructor(options5) {
|
|
8878
|
+
var _a, _b, _c, _d, _e, _f;
|
|
8879
|
+
_Client_auth.set(this, void 0);
|
|
8880
|
+
_Client_logLevel.set(this, void 0);
|
|
8881
|
+
_Client_logger.set(this, void 0);
|
|
8882
|
+
_Client_prefixUrl.set(this, void 0);
|
|
8883
|
+
_Client_timeoutMs.set(this, void 0);
|
|
8884
|
+
_Client_notionVersion.set(this, void 0);
|
|
8885
|
+
_Client_fetch.set(this, void 0);
|
|
8886
|
+
_Client_agent.set(this, void 0);
|
|
8887
|
+
_Client_userAgent.set(this, void 0);
|
|
8888
|
+
this.blocks = {
|
|
8889
|
+
/**
|
|
8890
|
+
* Retrieve block
|
|
8891
|
+
*/
|
|
8892
|
+
retrieve: (args2) => {
|
|
8893
|
+
return this.request({
|
|
8894
|
+
path: api_endpoints_1.getBlock.path(args2),
|
|
8895
|
+
method: api_endpoints_1.getBlock.method,
|
|
8896
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getBlock.queryParams),
|
|
8897
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getBlock.bodyParams),
|
|
8898
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8899
|
+
});
|
|
8900
|
+
},
|
|
8901
|
+
/**
|
|
8902
|
+
* Update block
|
|
8903
|
+
*/
|
|
8904
|
+
update: (args2) => {
|
|
8905
|
+
return this.request({
|
|
8906
|
+
path: api_endpoints_1.updateBlock.path(args2),
|
|
8907
|
+
method: api_endpoints_1.updateBlock.method,
|
|
8908
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.updateBlock.queryParams),
|
|
8909
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.updateBlock.bodyParams),
|
|
8910
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8911
|
+
});
|
|
8912
|
+
},
|
|
8913
|
+
/**
|
|
8914
|
+
* Delete block
|
|
8915
|
+
*/
|
|
8916
|
+
delete: (args2) => {
|
|
8917
|
+
return this.request({
|
|
8918
|
+
path: api_endpoints_1.deleteBlock.path(args2),
|
|
8919
|
+
method: api_endpoints_1.deleteBlock.method,
|
|
8920
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.deleteBlock.queryParams),
|
|
8921
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.deleteBlock.bodyParams),
|
|
8922
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8923
|
+
});
|
|
8924
|
+
},
|
|
8925
|
+
children: {
|
|
8926
|
+
/**
|
|
8927
|
+
* Append block children
|
|
8928
|
+
*/
|
|
8929
|
+
append: (args2) => {
|
|
8930
|
+
return this.request({
|
|
8931
|
+
path: api_endpoints_1.appendBlockChildren.path(args2),
|
|
8932
|
+
method: api_endpoints_1.appendBlockChildren.method,
|
|
8933
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.appendBlockChildren.queryParams),
|
|
8934
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.appendBlockChildren.bodyParams),
|
|
8935
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8936
|
+
});
|
|
8937
|
+
},
|
|
8938
|
+
/**
|
|
8939
|
+
* Retrieve block children
|
|
8940
|
+
*/
|
|
8941
|
+
list: (args2) => {
|
|
8942
|
+
return this.request({
|
|
8943
|
+
path: api_endpoints_1.listBlockChildren.path(args2),
|
|
8944
|
+
method: api_endpoints_1.listBlockChildren.method,
|
|
8945
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.listBlockChildren.queryParams),
|
|
8946
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.listBlockChildren.bodyParams),
|
|
8947
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8948
|
+
});
|
|
8949
|
+
}
|
|
8950
|
+
}
|
|
8951
|
+
};
|
|
8952
|
+
this.databases = {
|
|
8953
|
+
/**
|
|
8954
|
+
* Retrieve a database
|
|
8955
|
+
*/
|
|
8956
|
+
retrieve: (args2) => {
|
|
8957
|
+
return this.request({
|
|
8958
|
+
path: api_endpoints_1.getDatabase.path(args2),
|
|
8959
|
+
method: api_endpoints_1.getDatabase.method,
|
|
8960
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getDatabase.queryParams),
|
|
8961
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getDatabase.bodyParams),
|
|
8962
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8963
|
+
});
|
|
8964
|
+
},
|
|
8965
|
+
/**
|
|
8966
|
+
* Create a database
|
|
8967
|
+
*/
|
|
8968
|
+
create: (args2) => {
|
|
8969
|
+
return this.request({
|
|
8970
|
+
path: api_endpoints_1.createDatabase.path(),
|
|
8971
|
+
method: api_endpoints_1.createDatabase.method,
|
|
8972
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.createDatabase.queryParams),
|
|
8973
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.createDatabase.bodyParams),
|
|
8974
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8975
|
+
});
|
|
8976
|
+
},
|
|
8977
|
+
/**
|
|
8978
|
+
* Update a database
|
|
8979
|
+
*/
|
|
8980
|
+
update: (args2) => {
|
|
8981
|
+
return this.request({
|
|
8982
|
+
path: api_endpoints_1.updateDatabase.path(args2),
|
|
8983
|
+
method: api_endpoints_1.updateDatabase.method,
|
|
8984
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.updateDatabase.queryParams),
|
|
8985
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.updateDatabase.bodyParams),
|
|
8986
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
8987
|
+
});
|
|
8988
|
+
}
|
|
8989
|
+
};
|
|
8990
|
+
this.dataSources = {
|
|
8991
|
+
/**
|
|
8992
|
+
* Retrieve a data source
|
|
8993
|
+
*/
|
|
8994
|
+
retrieve: (args2) => {
|
|
8995
|
+
return this.request({
|
|
8996
|
+
path: api_endpoints_1.getDataSource.path(args2),
|
|
8997
|
+
method: api_endpoints_1.getDataSource.method,
|
|
8998
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getDataSource.queryParams),
|
|
8999
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getDataSource.bodyParams),
|
|
9000
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9001
|
+
});
|
|
9002
|
+
},
|
|
9003
|
+
/**
|
|
9004
|
+
* Query a data source
|
|
9005
|
+
*/
|
|
9006
|
+
query: (args2) => {
|
|
9007
|
+
return this.request({
|
|
9008
|
+
path: api_endpoints_1.queryDataSource.path(args2),
|
|
9009
|
+
method: api_endpoints_1.queryDataSource.method,
|
|
9010
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.queryDataSource.queryParams),
|
|
9011
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.queryDataSource.bodyParams),
|
|
9012
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9013
|
+
});
|
|
9014
|
+
},
|
|
9015
|
+
/**
|
|
9016
|
+
* Create a data source
|
|
9017
|
+
*/
|
|
9018
|
+
create: (args2) => {
|
|
9019
|
+
return this.request({
|
|
9020
|
+
path: api_endpoints_1.createDataSource.path(),
|
|
9021
|
+
method: api_endpoints_1.createDataSource.method,
|
|
9022
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.createDataSource.queryParams),
|
|
9023
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.createDataSource.bodyParams),
|
|
9024
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9025
|
+
});
|
|
9026
|
+
},
|
|
9027
|
+
/**
|
|
9028
|
+
* Update a data source
|
|
9029
|
+
*/
|
|
9030
|
+
update: (args2) => {
|
|
9031
|
+
return this.request({
|
|
9032
|
+
path: api_endpoints_1.updateDataSource.path(args2),
|
|
9033
|
+
method: api_endpoints_1.updateDataSource.method,
|
|
9034
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.updateDataSource.queryParams),
|
|
9035
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.updateDataSource.bodyParams),
|
|
9036
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9037
|
+
});
|
|
9038
|
+
},
|
|
9039
|
+
/**
|
|
9040
|
+
* List page templates that are available for a data source
|
|
9041
|
+
*/
|
|
9042
|
+
listTemplates: (args2) => {
|
|
9043
|
+
return this.request({
|
|
9044
|
+
path: api_endpoints_1.listDataSourceTemplates.path(args2),
|
|
9045
|
+
method: api_endpoints_1.listDataSourceTemplates.method,
|
|
9046
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.listDataSourceTemplates.queryParams),
|
|
9047
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.listDataSourceTemplates.bodyParams),
|
|
9048
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9049
|
+
});
|
|
9050
|
+
}
|
|
9051
|
+
};
|
|
9052
|
+
this.pages = {
|
|
9053
|
+
/**
|
|
9054
|
+
* Create a page
|
|
9055
|
+
*/
|
|
9056
|
+
create: (args2) => {
|
|
9057
|
+
return this.request({
|
|
9058
|
+
path: api_endpoints_1.createPage.path(),
|
|
9059
|
+
method: api_endpoints_1.createPage.method,
|
|
9060
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.createPage.queryParams),
|
|
9061
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.createPage.bodyParams),
|
|
9062
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9063
|
+
});
|
|
9064
|
+
},
|
|
9065
|
+
/**
|
|
9066
|
+
* Retrieve a page
|
|
9067
|
+
*/
|
|
9068
|
+
retrieve: (args2) => {
|
|
9069
|
+
return this.request({
|
|
9070
|
+
path: api_endpoints_1.getPage.path(args2),
|
|
9071
|
+
method: api_endpoints_1.getPage.method,
|
|
9072
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getPage.queryParams),
|
|
9073
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getPage.bodyParams),
|
|
9074
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9075
|
+
});
|
|
9076
|
+
},
|
|
9077
|
+
/**
|
|
9078
|
+
* Update page properties
|
|
9079
|
+
*/
|
|
9080
|
+
update: (args2) => {
|
|
9081
|
+
return this.request({
|
|
9082
|
+
path: api_endpoints_1.updatePage.path(args2),
|
|
9083
|
+
method: api_endpoints_1.updatePage.method,
|
|
9084
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.updatePage.queryParams),
|
|
9085
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.updatePage.bodyParams),
|
|
9086
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9087
|
+
});
|
|
9088
|
+
},
|
|
9089
|
+
/**
|
|
9090
|
+
* Move a page
|
|
9091
|
+
*/
|
|
9092
|
+
move: (args2) => {
|
|
9093
|
+
return this.request({
|
|
9094
|
+
path: api_endpoints_1.movePage.path(args2),
|
|
9095
|
+
method: api_endpoints_1.movePage.method,
|
|
9096
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.movePage.queryParams),
|
|
9097
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.movePage.bodyParams),
|
|
9098
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9099
|
+
});
|
|
9100
|
+
},
|
|
9101
|
+
properties: {
|
|
9102
|
+
/**
|
|
9103
|
+
* Retrieve page property
|
|
9104
|
+
*/
|
|
9105
|
+
retrieve: (args2) => {
|
|
9106
|
+
return this.request({
|
|
9107
|
+
path: api_endpoints_1.getPageProperty.path(args2),
|
|
9108
|
+
method: api_endpoints_1.getPageProperty.method,
|
|
9109
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getPageProperty.queryParams),
|
|
9110
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getPageProperty.bodyParams),
|
|
9111
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9112
|
+
});
|
|
9113
|
+
}
|
|
9114
|
+
}
|
|
9115
|
+
};
|
|
9116
|
+
this.users = {
|
|
9117
|
+
/**
|
|
9118
|
+
* Retrieve a user
|
|
9119
|
+
*/
|
|
9120
|
+
retrieve: (args2) => {
|
|
9121
|
+
return this.request({
|
|
9122
|
+
path: api_endpoints_1.getUser.path(args2),
|
|
9123
|
+
method: api_endpoints_1.getUser.method,
|
|
9124
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getUser.queryParams),
|
|
9125
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getUser.bodyParams),
|
|
9126
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9127
|
+
});
|
|
9128
|
+
},
|
|
9129
|
+
/**
|
|
9130
|
+
* List all users
|
|
9131
|
+
*/
|
|
9132
|
+
list: (args2) => {
|
|
9133
|
+
return this.request({
|
|
9134
|
+
path: api_endpoints_1.listUsers.path(),
|
|
9135
|
+
method: api_endpoints_1.listUsers.method,
|
|
9136
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.listUsers.queryParams),
|
|
9137
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.listUsers.bodyParams),
|
|
9138
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9139
|
+
});
|
|
9140
|
+
},
|
|
9141
|
+
/**
|
|
9142
|
+
* Get details about bot
|
|
9143
|
+
*/
|
|
9144
|
+
me: (args2) => {
|
|
9145
|
+
return this.request({
|
|
9146
|
+
path: api_endpoints_1.getSelf.path(),
|
|
9147
|
+
method: api_endpoints_1.getSelf.method,
|
|
9148
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getSelf.queryParams),
|
|
9149
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getSelf.bodyParams),
|
|
9150
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9151
|
+
});
|
|
9152
|
+
}
|
|
9153
|
+
};
|
|
9154
|
+
this.comments = {
|
|
9155
|
+
/**
|
|
9156
|
+
* Create a comment
|
|
9157
|
+
*/
|
|
9158
|
+
create: (args2) => {
|
|
9159
|
+
return this.request({
|
|
9160
|
+
path: api_endpoints_1.createComment.path(),
|
|
9161
|
+
method: api_endpoints_1.createComment.method,
|
|
9162
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.createComment.queryParams),
|
|
9163
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.createComment.bodyParams),
|
|
9164
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9165
|
+
});
|
|
9166
|
+
},
|
|
9167
|
+
/**
|
|
9168
|
+
* List comments
|
|
9169
|
+
*/
|
|
9170
|
+
list: (args2) => {
|
|
9171
|
+
return this.request({
|
|
9172
|
+
path: api_endpoints_1.listComments.path(),
|
|
9173
|
+
method: api_endpoints_1.listComments.method,
|
|
9174
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.listComments.queryParams),
|
|
9175
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.listComments.bodyParams),
|
|
9176
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9177
|
+
});
|
|
9178
|
+
},
|
|
9179
|
+
/**
|
|
9180
|
+
* Retrieve a comment
|
|
9181
|
+
*/
|
|
9182
|
+
retrieve: (args2) => {
|
|
9183
|
+
return this.request({
|
|
9184
|
+
path: api_endpoints_1.getComment.path(args2),
|
|
9185
|
+
method: api_endpoints_1.getComment.method,
|
|
9186
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getComment.queryParams),
|
|
9187
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.getComment.bodyParams),
|
|
9188
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9189
|
+
});
|
|
9190
|
+
}
|
|
9191
|
+
};
|
|
9192
|
+
this.fileUploads = {
|
|
9193
|
+
/**
|
|
9194
|
+
* Create a file upload
|
|
9195
|
+
*/
|
|
9196
|
+
create: (args2) => {
|
|
9197
|
+
return this.request({
|
|
9198
|
+
path: api_endpoints_1.createFileUpload.path(),
|
|
9199
|
+
method: api_endpoints_1.createFileUpload.method,
|
|
9200
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.createFileUpload.queryParams),
|
|
9201
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.createFileUpload.bodyParams),
|
|
9202
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9203
|
+
});
|
|
9204
|
+
},
|
|
9205
|
+
/**
|
|
9206
|
+
* Retrieve a file upload
|
|
9207
|
+
*/
|
|
9208
|
+
retrieve: (args2) => {
|
|
9209
|
+
return this.request({
|
|
9210
|
+
path: api_endpoints_1.getFileUpload.path(args2),
|
|
9211
|
+
method: api_endpoints_1.getFileUpload.method,
|
|
9212
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.getFileUpload.queryParams),
|
|
9213
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9214
|
+
});
|
|
9215
|
+
},
|
|
9216
|
+
/**
|
|
9217
|
+
* List file uploads
|
|
9218
|
+
*/
|
|
9219
|
+
list: (args2) => {
|
|
9220
|
+
return this.request({
|
|
9221
|
+
path: api_endpoints_1.listFileUploads.path(),
|
|
9222
|
+
method: api_endpoints_1.listFileUploads.method,
|
|
9223
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.listFileUploads.queryParams),
|
|
9224
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9225
|
+
});
|
|
9226
|
+
},
|
|
9227
|
+
/**
|
|
9228
|
+
* Send a file upload
|
|
9229
|
+
*
|
|
9230
|
+
* Requires a `file_upload_id`, obtained from the `id` of the Create File
|
|
9231
|
+
* Upload API response.
|
|
9232
|
+
*
|
|
9233
|
+
* The `file` parameter contains the raw file contents or Blob/File object
|
|
9234
|
+
* under `file.data`, and an optional `file.filename` string.
|
|
9235
|
+
*
|
|
9236
|
+
* Supply a stringified `part_number` parameter when using file uploads
|
|
9237
|
+
* in multi-part mode.
|
|
9238
|
+
*
|
|
9239
|
+
* This endpoint sends HTTP multipart/form-data instead of JSON parameters.
|
|
9240
|
+
*/
|
|
9241
|
+
send: (args2) => {
|
|
9242
|
+
return this.request({
|
|
9243
|
+
path: api_endpoints_1.sendFileUpload.path(args2),
|
|
9244
|
+
method: api_endpoints_1.sendFileUpload.method,
|
|
9245
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.sendFileUpload.queryParams),
|
|
9246
|
+
formDataParams: (0, utils_1.pick)(args2, api_endpoints_1.sendFileUpload.formDataParams),
|
|
9247
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9248
|
+
});
|
|
9249
|
+
},
|
|
9250
|
+
/**
|
|
9251
|
+
* Complete a file upload
|
|
9252
|
+
*/
|
|
9253
|
+
complete: (args2) => {
|
|
9254
|
+
return this.request({
|
|
9255
|
+
path: api_endpoints_1.completeFileUpload.path(args2),
|
|
9256
|
+
method: api_endpoints_1.completeFileUpload.method,
|
|
9257
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.completeFileUpload.queryParams),
|
|
9258
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9259
|
+
});
|
|
9260
|
+
}
|
|
9261
|
+
};
|
|
9262
|
+
this.search = (args2) => {
|
|
9263
|
+
return this.request({
|
|
9264
|
+
path: api_endpoints_1.search.path(),
|
|
9265
|
+
method: api_endpoints_1.search.method,
|
|
9266
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.search.queryParams),
|
|
9267
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.search.bodyParams),
|
|
9268
|
+
auth: args2 === null || args2 === void 0 ? void 0 : args2.auth
|
|
9269
|
+
});
|
|
9270
|
+
};
|
|
9271
|
+
this.oauth = {
|
|
9272
|
+
/**
|
|
9273
|
+
* Get token
|
|
9274
|
+
*/
|
|
9275
|
+
token: (args2) => {
|
|
9276
|
+
return this.request({
|
|
9277
|
+
path: api_endpoints_1.oauthToken.path(),
|
|
9278
|
+
method: api_endpoints_1.oauthToken.method,
|
|
9279
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.oauthToken.queryParams),
|
|
9280
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.oauthToken.bodyParams),
|
|
9281
|
+
auth: {
|
|
9282
|
+
client_id: args2.client_id,
|
|
9283
|
+
client_secret: args2.client_secret
|
|
9284
|
+
}
|
|
9285
|
+
});
|
|
9286
|
+
},
|
|
9287
|
+
/**
|
|
9288
|
+
* Introspect token
|
|
9289
|
+
*/
|
|
9290
|
+
introspect: (args2) => {
|
|
9291
|
+
return this.request({
|
|
9292
|
+
path: api_endpoints_1.oauthIntrospect.path(),
|
|
9293
|
+
method: api_endpoints_1.oauthIntrospect.method,
|
|
9294
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.oauthIntrospect.queryParams),
|
|
9295
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.oauthIntrospect.bodyParams),
|
|
9296
|
+
auth: {
|
|
9297
|
+
client_id: args2.client_id,
|
|
9298
|
+
client_secret: args2.client_secret
|
|
9299
|
+
}
|
|
9300
|
+
});
|
|
9301
|
+
},
|
|
9302
|
+
/**
|
|
9303
|
+
* Revoke token
|
|
9304
|
+
*/
|
|
9305
|
+
revoke: (args2) => {
|
|
9306
|
+
return this.request({
|
|
9307
|
+
path: api_endpoints_1.oauthRevoke.path(),
|
|
9308
|
+
method: api_endpoints_1.oauthRevoke.method,
|
|
9309
|
+
query: (0, utils_1.pick)(args2, api_endpoints_1.oauthRevoke.queryParams),
|
|
9310
|
+
body: (0, utils_1.pick)(args2, api_endpoints_1.oauthRevoke.bodyParams),
|
|
9311
|
+
auth: {
|
|
9312
|
+
client_id: args2.client_id,
|
|
9313
|
+
client_secret: args2.client_secret
|
|
9314
|
+
}
|
|
9315
|
+
});
|
|
9316
|
+
}
|
|
9317
|
+
};
|
|
9318
|
+
__classPrivateFieldSet(this, _Client_auth, options5 === null || options5 === void 0 ? void 0 : options5.auth, "f");
|
|
9319
|
+
__classPrivateFieldSet(this, _Client_logLevel, (_a = options5 === null || options5 === void 0 ? void 0 : options5.logLevel) !== null && _a !== void 0 ? _a : logging_1.LogLevel.WARN, "f");
|
|
9320
|
+
__classPrivateFieldSet(this, _Client_logger, (_b = options5 === null || options5 === void 0 ? void 0 : options5.logger) !== null && _b !== void 0 ? _b : (0, logging_1.makeConsoleLogger)(package_json_1.name), "f");
|
|
9321
|
+
__classPrivateFieldSet(this, _Client_prefixUrl, `${(_c = options5 === null || options5 === void 0 ? void 0 : options5.baseUrl) !== null && _c !== void 0 ? _c : "https://api.notion.com"}/v1/`, "f");
|
|
9322
|
+
__classPrivateFieldSet(this, _Client_timeoutMs, (_d = options5 === null || options5 === void 0 ? void 0 : options5.timeoutMs) !== null && _d !== void 0 ? _d : 6e4, "f");
|
|
9323
|
+
__classPrivateFieldSet(this, _Client_notionVersion, (_e = options5 === null || options5 === void 0 ? void 0 : options5.notionVersion) !== null && _e !== void 0 ? _e : _Client.defaultNotionVersion, "f");
|
|
9324
|
+
__classPrivateFieldSet(this, _Client_fetch, (_f = options5 === null || options5 === void 0 ? void 0 : options5.fetch) !== null && _f !== void 0 ? _f : fetch, "f");
|
|
9325
|
+
__classPrivateFieldSet(this, _Client_agent, options5 === null || options5 === void 0 ? void 0 : options5.agent, "f");
|
|
9326
|
+
__classPrivateFieldSet(this, _Client_userAgent, `notionhq-client/${package_json_1.version}`, "f");
|
|
9327
|
+
}
|
|
9328
|
+
/**
|
|
9329
|
+
* Sends a request.
|
|
9330
|
+
*/
|
|
9331
|
+
async request(args2) {
|
|
9332
|
+
const { path: path3, method, query, body, formDataParams, auth } = args2;
|
|
9333
|
+
this.log(logging_1.LogLevel.INFO, "request start", { method, path: path3 });
|
|
9334
|
+
const bodyAsJsonString = !body || Object.entries(body).length === 0 ? void 0 : JSON.stringify(body);
|
|
9335
|
+
const url2 = new URL(`${__classPrivateFieldGet(this, _Client_prefixUrl, "f")}${path3}`);
|
|
9336
|
+
if (query) {
|
|
9337
|
+
for (const [key, value5] of Object.entries(query)) {
|
|
9338
|
+
if (value5 !== void 0) {
|
|
9339
|
+
if (Array.isArray(value5)) {
|
|
9340
|
+
for (const val of value5) {
|
|
9341
|
+
url2.searchParams.append(key, decodeURIComponent(val));
|
|
9342
|
+
}
|
|
9343
|
+
} else {
|
|
9344
|
+
url2.searchParams.append(key, String(value5));
|
|
9345
|
+
}
|
|
9346
|
+
}
|
|
9347
|
+
}
|
|
9348
|
+
}
|
|
9349
|
+
let authorizationHeader;
|
|
9350
|
+
if (typeof auth === "object") {
|
|
9351
|
+
const unencodedCredential = `${auth.client_id}:${auth.client_secret}`;
|
|
9352
|
+
const encodedCredential = Buffer.from(unencodedCredential).toString("base64");
|
|
9353
|
+
authorizationHeader = { authorization: `Basic ${encodedCredential}` };
|
|
9354
|
+
} else {
|
|
9355
|
+
authorizationHeader = this.authAsHeaders(auth);
|
|
9356
|
+
}
|
|
9357
|
+
const headers = {
|
|
9358
|
+
// Request-level custom additional headers can be provided, but
|
|
9359
|
+
// don't allow them to override all other headers, e.g. the
|
|
9360
|
+
// standard user agent.
|
|
9361
|
+
...args2.headers,
|
|
9362
|
+
...authorizationHeader,
|
|
9363
|
+
"Notion-Version": __classPrivateFieldGet(this, _Client_notionVersion, "f"),
|
|
9364
|
+
"user-agent": __classPrivateFieldGet(this, _Client_userAgent, "f")
|
|
9365
|
+
};
|
|
9366
|
+
if (bodyAsJsonString !== void 0) {
|
|
9367
|
+
headers["content-type"] = "application/json";
|
|
9368
|
+
}
|
|
9369
|
+
let formData2;
|
|
9370
|
+
if (formDataParams) {
|
|
9371
|
+
delete headers["content-type"];
|
|
9372
|
+
formData2 = new FormData();
|
|
9373
|
+
for (const [key, value5] of Object.entries(formDataParams)) {
|
|
9374
|
+
if (typeof value5 === "string") {
|
|
9375
|
+
formData2.append(key, value5);
|
|
9376
|
+
} else if (typeof value5 === "object") {
|
|
9377
|
+
formData2.append(key, typeof value5.data === "object" ? value5.data : new Blob([value5.data]), value5.filename);
|
|
9378
|
+
}
|
|
9379
|
+
}
|
|
9380
|
+
}
|
|
9381
|
+
try {
|
|
9382
|
+
const response = await errors_1.RequestTimeoutError.rejectAfterTimeout(__classPrivateFieldGet(this, _Client_fetch, "f").call(this, url2.toString(), {
|
|
9383
|
+
method: method.toUpperCase(),
|
|
9384
|
+
headers,
|
|
9385
|
+
body: bodyAsJsonString !== null && bodyAsJsonString !== void 0 ? bodyAsJsonString : formData2,
|
|
9386
|
+
agent: __classPrivateFieldGet(this, _Client_agent, "f")
|
|
9387
|
+
}), __classPrivateFieldGet(this, _Client_timeoutMs, "f"));
|
|
9388
|
+
const responseText = await response.text();
|
|
9389
|
+
if (!response.ok) {
|
|
9390
|
+
throw (0, errors_1.buildRequestError)(response, responseText);
|
|
9391
|
+
}
|
|
9392
|
+
const responseJson = JSON.parse(responseText);
|
|
9393
|
+
this.log(logging_1.LogLevel.INFO, "request success", {
|
|
9394
|
+
method,
|
|
9395
|
+
path: path3,
|
|
9396
|
+
..."request_id" in responseJson && responseJson.request_id ? { requestId: responseJson.request_id } : {}
|
|
9397
|
+
});
|
|
9398
|
+
return responseJson;
|
|
9399
|
+
} catch (error4) {
|
|
9400
|
+
if (!(0, errors_1.isNotionClientError)(error4)) {
|
|
9401
|
+
throw error4;
|
|
9402
|
+
}
|
|
9403
|
+
this.log(logging_1.LogLevel.WARN, "request fail", {
|
|
9404
|
+
code: error4.code,
|
|
9405
|
+
message: error4.message,
|
|
9406
|
+
..."request_id" in error4 && error4.request_id ? { requestId: error4.request_id } : {}
|
|
9407
|
+
});
|
|
9408
|
+
if ((0, errors_1.isHTTPResponseError)(error4)) {
|
|
9409
|
+
this.log(logging_1.LogLevel.DEBUG, "failed response body", {
|
|
9410
|
+
body: error4.body
|
|
9411
|
+
});
|
|
9412
|
+
}
|
|
9413
|
+
throw error4;
|
|
9414
|
+
}
|
|
9415
|
+
}
|
|
9416
|
+
/**
|
|
9417
|
+
* Emits a log message to the console.
|
|
9418
|
+
*
|
|
9419
|
+
* @param level The level for this message
|
|
9420
|
+
* @param args Arguments to send to the console
|
|
9421
|
+
*/
|
|
9422
|
+
log(level, message, extraInfo) {
|
|
9423
|
+
if ((0, logging_1.logLevelSeverity)(level) >= (0, logging_1.logLevelSeverity)(__classPrivateFieldGet(this, _Client_logLevel, "f"))) {
|
|
9424
|
+
__classPrivateFieldGet(this, _Client_logger, "f").call(this, level, message, extraInfo);
|
|
9425
|
+
}
|
|
9426
|
+
}
|
|
9427
|
+
/**
|
|
9428
|
+
* Transforms an API key or access token into a headers object suitable for an HTTP request.
|
|
9429
|
+
*
|
|
9430
|
+
* This method uses the instance's value as the default when the input is undefined. If neither are defined, it returns
|
|
9431
|
+
* an empty object
|
|
9432
|
+
*
|
|
9433
|
+
* @param auth API key or access token
|
|
9434
|
+
* @returns headers key-value object
|
|
9435
|
+
*/
|
|
9436
|
+
authAsHeaders(auth) {
|
|
9437
|
+
const headers = {};
|
|
9438
|
+
const authHeaderValue = auth !== null && auth !== void 0 ? auth : __classPrivateFieldGet(this, _Client_auth, "f");
|
|
9439
|
+
if (authHeaderValue !== void 0) {
|
|
9440
|
+
headers["authorization"] = `Bearer ${authHeaderValue}`;
|
|
9441
|
+
}
|
|
9442
|
+
return headers;
|
|
9443
|
+
}
|
|
9444
|
+
};
|
|
9445
|
+
_Client_auth = /* @__PURE__ */ new WeakMap(), _Client_logLevel = /* @__PURE__ */ new WeakMap(), _Client_logger = /* @__PURE__ */ new WeakMap(), _Client_prefixUrl = /* @__PURE__ */ new WeakMap(), _Client_timeoutMs = /* @__PURE__ */ new WeakMap(), _Client_notionVersion = /* @__PURE__ */ new WeakMap(), _Client_fetch = /* @__PURE__ */ new WeakMap(), _Client_agent = /* @__PURE__ */ new WeakMap(), _Client_userAgent = /* @__PURE__ */ new WeakMap();
|
|
9446
|
+
Client.defaultNotionVersion = "2025-09-03";
|
|
9447
|
+
exports$1.default = Client;
|
|
9448
|
+
}
|
|
9449
|
+
});
|
|
9450
|
+
|
|
9451
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/helpers.js
|
|
9452
|
+
var require_helpers = __commonJS({
|
|
9453
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/helpers.js"(exports$1) {
|
|
9454
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
9455
|
+
exports$1.iteratePaginatedAPI = iteratePaginatedAPI;
|
|
9456
|
+
exports$1.collectPaginatedAPI = collectPaginatedAPI;
|
|
9457
|
+
exports$1.iterateDataSourceTemplates = iterateDataSourceTemplates;
|
|
9458
|
+
exports$1.collectDataSourceTemplates = collectDataSourceTemplates;
|
|
9459
|
+
exports$1.isFullBlock = isFullBlock;
|
|
9460
|
+
exports$1.isFullPage = isFullPage;
|
|
9461
|
+
exports$1.isFullDataSource = isFullDataSource;
|
|
9462
|
+
exports$1.isFullDatabase = isFullDatabase;
|
|
9463
|
+
exports$1.isFullPageOrDataSource = isFullPageOrDataSource;
|
|
9464
|
+
exports$1.isFullUser = isFullUser;
|
|
9465
|
+
exports$1.isFullComment = isFullComment;
|
|
9466
|
+
exports$1.isTextRichTextItemResponse = isTextRichTextItemResponse;
|
|
9467
|
+
exports$1.isEquationRichTextItemResponse = isEquationRichTextItemResponse;
|
|
9468
|
+
exports$1.isMentionRichTextItemResponse = isMentionRichTextItemResponse;
|
|
9469
|
+
exports$1.extractNotionId = extractNotionId;
|
|
9470
|
+
exports$1.extractDatabaseId = extractDatabaseId;
|
|
9471
|
+
exports$1.extractPageId = extractPageId;
|
|
9472
|
+
exports$1.extractBlockId = extractBlockId;
|
|
9473
|
+
async function* iteratePaginatedAPI(listFn, firstPageArgs) {
|
|
9474
|
+
let nextCursor = firstPageArgs.start_cursor;
|
|
9475
|
+
do {
|
|
9476
|
+
const response = await listFn({
|
|
9477
|
+
...firstPageArgs,
|
|
9478
|
+
start_cursor: nextCursor
|
|
9479
|
+
});
|
|
9480
|
+
yield* response.results;
|
|
9481
|
+
nextCursor = response.next_cursor;
|
|
9482
|
+
} while (nextCursor);
|
|
9483
|
+
}
|
|
9484
|
+
async function collectPaginatedAPI(listFn, firstPageArgs) {
|
|
9485
|
+
const results = [];
|
|
9486
|
+
for await (const item of iteratePaginatedAPI(listFn, firstPageArgs)) {
|
|
9487
|
+
results.push(item);
|
|
9488
|
+
}
|
|
9489
|
+
return results;
|
|
9490
|
+
}
|
|
9491
|
+
async function* iterateDataSourceTemplates(client, args2) {
|
|
9492
|
+
let nextCursor = args2.start_cursor;
|
|
9493
|
+
do {
|
|
9494
|
+
const response = await client.dataSources.listTemplates({
|
|
9495
|
+
...args2,
|
|
9496
|
+
start_cursor: nextCursor
|
|
9497
|
+
});
|
|
9498
|
+
yield* response.templates;
|
|
9499
|
+
nextCursor = response.next_cursor;
|
|
9500
|
+
} while (nextCursor);
|
|
9501
|
+
}
|
|
9502
|
+
async function collectDataSourceTemplates(client, args2) {
|
|
9503
|
+
const results = [];
|
|
9504
|
+
for await (const template of iterateDataSourceTemplates(client, args2)) {
|
|
9505
|
+
results.push(template);
|
|
9506
|
+
}
|
|
9507
|
+
return results;
|
|
9508
|
+
}
|
|
9509
|
+
function isFullBlock(response) {
|
|
9510
|
+
return response.object === "block" && "type" in response;
|
|
9511
|
+
}
|
|
9512
|
+
function isFullPage(response) {
|
|
9513
|
+
return response.object === "page" && "url" in response;
|
|
9514
|
+
}
|
|
9515
|
+
function isFullDataSource(response) {
|
|
9516
|
+
return response.object === "data_source";
|
|
9517
|
+
}
|
|
9518
|
+
function isFullDatabase(response) {
|
|
9519
|
+
return response.object === "database";
|
|
9520
|
+
}
|
|
9521
|
+
function isFullPageOrDataSource(response) {
|
|
9522
|
+
if (response.object === "data_source") {
|
|
9523
|
+
return isFullDataSource(response);
|
|
9524
|
+
} else {
|
|
9525
|
+
return isFullPage(response);
|
|
9526
|
+
}
|
|
9527
|
+
}
|
|
9528
|
+
function isFullUser(response) {
|
|
9529
|
+
return "type" in response;
|
|
9530
|
+
}
|
|
9531
|
+
function isFullComment(response) {
|
|
9532
|
+
return "created_by" in response;
|
|
9533
|
+
}
|
|
9534
|
+
function isTextRichTextItemResponse(richText) {
|
|
9535
|
+
return richText.type === "text";
|
|
9536
|
+
}
|
|
9537
|
+
function isEquationRichTextItemResponse(richText) {
|
|
9538
|
+
return richText.type === "equation";
|
|
9539
|
+
}
|
|
9540
|
+
function isMentionRichTextItemResponse(richText) {
|
|
9541
|
+
return richText.type === "mention";
|
|
9542
|
+
}
|
|
9543
|
+
function extractNotionId(urlOrId) {
|
|
9544
|
+
if (!urlOrId || typeof urlOrId !== "string") {
|
|
9545
|
+
return null;
|
|
9546
|
+
}
|
|
9547
|
+
const trimmed = urlOrId.trim();
|
|
9548
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
9549
|
+
if (uuidRegex.test(trimmed)) {
|
|
9550
|
+
return trimmed.toLowerCase();
|
|
9551
|
+
}
|
|
9552
|
+
const compactUuidRegex = /^[0-9a-f]{32}$/i;
|
|
9553
|
+
if (compactUuidRegex.test(trimmed)) {
|
|
9554
|
+
return formatUuid(trimmed);
|
|
9555
|
+
}
|
|
9556
|
+
const pathMatch = trimmed.match(/\/[^/?#]*-([0-9a-f]{32})(?:[/?#]|$)/i);
|
|
9557
|
+
if (pathMatch && pathMatch[1]) {
|
|
9558
|
+
return formatUuid(pathMatch[1]);
|
|
9559
|
+
}
|
|
9560
|
+
const queryMatch = trimmed.match(/[?&](?:p|page_id|database_id)=([0-9a-f]{32})/i);
|
|
9561
|
+
if (queryMatch && queryMatch[1]) {
|
|
9562
|
+
return formatUuid(queryMatch[1]);
|
|
9563
|
+
}
|
|
9564
|
+
const anyMatch = trimmed.match(/([0-9a-f]{32})/i);
|
|
9565
|
+
if (anyMatch && anyMatch[1]) {
|
|
9566
|
+
return formatUuid(anyMatch[1]);
|
|
9567
|
+
}
|
|
9568
|
+
return null;
|
|
9569
|
+
}
|
|
9570
|
+
function formatUuid(compactId) {
|
|
9571
|
+
const clean = compactId.toLowerCase();
|
|
9572
|
+
return `${clean.slice(0, 8)}-${clean.slice(8, 12)}-${clean.slice(12, 16)}-${clean.slice(16, 20)}-${clean.slice(20, 32)}`;
|
|
9573
|
+
}
|
|
9574
|
+
function extractDatabaseId(databaseUrl) {
|
|
9575
|
+
return extractNotionId(databaseUrl);
|
|
9576
|
+
}
|
|
9577
|
+
function extractPageId(pageUrl) {
|
|
9578
|
+
return extractNotionId(pageUrl);
|
|
9579
|
+
}
|
|
9580
|
+
function extractBlockId(urlWithBlock) {
|
|
9581
|
+
if (!urlWithBlock || typeof urlWithBlock !== "string") {
|
|
9582
|
+
return null;
|
|
9583
|
+
}
|
|
9584
|
+
const blockMatch = urlWithBlock.match(/#(?:block-)?([0-9a-f]{32})/i);
|
|
9585
|
+
if (blockMatch && blockMatch[1]) {
|
|
9586
|
+
return formatUuid(blockMatch[1]);
|
|
9587
|
+
}
|
|
9588
|
+
return null;
|
|
9589
|
+
}
|
|
9590
|
+
}
|
|
9591
|
+
});
|
|
9592
|
+
|
|
9593
|
+
// ../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/index.js
|
|
9594
|
+
var require_src2 = __commonJS({
|
|
9595
|
+
"../../node_modules/.pnpm/@notionhq+client@5.6.0/node_modules/@notionhq/client/build/src/index.js"(exports$1) {
|
|
9596
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
9597
|
+
exports$1.extractBlockId = exports$1.extractPageId = exports$1.extractDatabaseId = exports$1.extractNotionId = exports$1.isFullPageOrDataSource = exports$1.isFullComment = exports$1.isFullUser = exports$1.isFullPage = exports$1.isFullDatabase = exports$1.isFullDataSource = exports$1.isFullBlock = exports$1.iterateDataSourceTemplates = exports$1.collectDataSourceTemplates = exports$1.iteratePaginatedAPI = exports$1.collectPaginatedAPI = exports$1.isNotionClientError = exports$1.RequestTimeoutError = exports$1.UnknownHTTPResponseError = exports$1.APIResponseError = exports$1.ClientErrorCode = exports$1.APIErrorCode = exports$1.LogLevel = exports$1.Client = void 0;
|
|
9598
|
+
var Client_1 = require_Client();
|
|
9599
|
+
Object.defineProperty(exports$1, "Client", { enumerable: true, get: function() {
|
|
9600
|
+
return Client_1.default;
|
|
9601
|
+
} });
|
|
9602
|
+
var logging_1 = require_logging();
|
|
9603
|
+
Object.defineProperty(exports$1, "LogLevel", { enumerable: true, get: function() {
|
|
9604
|
+
return logging_1.LogLevel;
|
|
9605
|
+
} });
|
|
9606
|
+
var errors_1 = require_errors2();
|
|
9607
|
+
Object.defineProperty(exports$1, "APIErrorCode", { enumerable: true, get: function() {
|
|
9608
|
+
return errors_1.APIErrorCode;
|
|
9609
|
+
} });
|
|
9610
|
+
Object.defineProperty(exports$1, "ClientErrorCode", { enumerable: true, get: function() {
|
|
9611
|
+
return errors_1.ClientErrorCode;
|
|
9612
|
+
} });
|
|
9613
|
+
Object.defineProperty(exports$1, "APIResponseError", { enumerable: true, get: function() {
|
|
9614
|
+
return errors_1.APIResponseError;
|
|
9615
|
+
} });
|
|
9616
|
+
Object.defineProperty(exports$1, "UnknownHTTPResponseError", { enumerable: true, get: function() {
|
|
9617
|
+
return errors_1.UnknownHTTPResponseError;
|
|
9618
|
+
} });
|
|
9619
|
+
Object.defineProperty(exports$1, "RequestTimeoutError", { enumerable: true, get: function() {
|
|
9620
|
+
return errors_1.RequestTimeoutError;
|
|
9621
|
+
} });
|
|
9622
|
+
Object.defineProperty(exports$1, "isNotionClientError", { enumerable: true, get: function() {
|
|
9623
|
+
return errors_1.isNotionClientError;
|
|
9624
|
+
} });
|
|
9625
|
+
var helpers_1 = require_helpers();
|
|
9626
|
+
Object.defineProperty(exports$1, "collectPaginatedAPI", { enumerable: true, get: function() {
|
|
9627
|
+
return helpers_1.collectPaginatedAPI;
|
|
9628
|
+
} });
|
|
9629
|
+
Object.defineProperty(exports$1, "iteratePaginatedAPI", { enumerable: true, get: function() {
|
|
9630
|
+
return helpers_1.iteratePaginatedAPI;
|
|
9631
|
+
} });
|
|
9632
|
+
Object.defineProperty(exports$1, "collectDataSourceTemplates", { enumerable: true, get: function() {
|
|
9633
|
+
return helpers_1.collectDataSourceTemplates;
|
|
9634
|
+
} });
|
|
9635
|
+
Object.defineProperty(exports$1, "iterateDataSourceTemplates", { enumerable: true, get: function() {
|
|
9636
|
+
return helpers_1.iterateDataSourceTemplates;
|
|
9637
|
+
} });
|
|
9638
|
+
Object.defineProperty(exports$1, "isFullBlock", { enumerable: true, get: function() {
|
|
9639
|
+
return helpers_1.isFullBlock;
|
|
9640
|
+
} });
|
|
9641
|
+
Object.defineProperty(exports$1, "isFullDataSource", { enumerable: true, get: function() {
|
|
9642
|
+
return helpers_1.isFullDataSource;
|
|
9643
|
+
} });
|
|
9644
|
+
Object.defineProperty(exports$1, "isFullDatabase", { enumerable: true, get: function() {
|
|
9645
|
+
return helpers_1.isFullDatabase;
|
|
9646
|
+
} });
|
|
9647
|
+
Object.defineProperty(exports$1, "isFullPage", { enumerable: true, get: function() {
|
|
9648
|
+
return helpers_1.isFullPage;
|
|
9649
|
+
} });
|
|
9650
|
+
Object.defineProperty(exports$1, "isFullUser", { enumerable: true, get: function() {
|
|
9651
|
+
return helpers_1.isFullUser;
|
|
9652
|
+
} });
|
|
9653
|
+
Object.defineProperty(exports$1, "isFullComment", { enumerable: true, get: function() {
|
|
9654
|
+
return helpers_1.isFullComment;
|
|
9655
|
+
} });
|
|
9656
|
+
Object.defineProperty(exports$1, "isFullPageOrDataSource", { enumerable: true, get: function() {
|
|
9657
|
+
return helpers_1.isFullPageOrDataSource;
|
|
9658
|
+
} });
|
|
9659
|
+
Object.defineProperty(exports$1, "extractNotionId", { enumerable: true, get: function() {
|
|
9660
|
+
return helpers_1.extractNotionId;
|
|
9661
|
+
} });
|
|
9662
|
+
Object.defineProperty(exports$1, "extractDatabaseId", { enumerable: true, get: function() {
|
|
9663
|
+
return helpers_1.extractDatabaseId;
|
|
9664
|
+
} });
|
|
9665
|
+
Object.defineProperty(exports$1, "extractPageId", { enumerable: true, get: function() {
|
|
9666
|
+
return helpers_1.extractPageId;
|
|
9667
|
+
} });
|
|
9668
|
+
Object.defineProperty(exports$1, "extractBlockId", { enumerable: true, get: function() {
|
|
9669
|
+
return helpers_1.extractBlockId;
|
|
9670
|
+
} });
|
|
9671
|
+
}
|
|
9672
|
+
});
|
|
9673
|
+
|
|
8211
9674
|
// ../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/constants.js
|
|
8212
9675
|
var require_constants = __commonJS({
|
|
8213
9676
|
"../../node_modules/.pnpm/ws@8.18.3/node_modules/ws/lib/constants.js"(exports$1, module) {
|
|
@@ -30271,6 +31734,7 @@ var intersect6 = intersect5;
|
|
|
30271
31734
|
var recurWhile2 = recurWhile;
|
|
30272
31735
|
var recurs2 = recurs;
|
|
30273
31736
|
var spaced2 = spaced;
|
|
31737
|
+
var whileInput2 = whileInput;
|
|
30274
31738
|
var CurrentIterationMetadata2 = CurrentIterationMetadata;
|
|
30275
31739
|
|
|
30276
31740
|
// ../../node_modules/.pnpm/effect@3.19.14/node_modules/effect/dist/esm/internal/stream/emit.js
|
|
@@ -38105,6 +39569,7 @@ var UpdateMilestoneInput = class extends Class4(
|
|
|
38105
39569
|
var SHIP_WORKSPACES_DIR = "workspaces";
|
|
38106
39570
|
var DEFAULT_WORKSPACE_NAME = "default";
|
|
38107
39571
|
var DEFAULT_WORKSPACE_PATH_PATTERN = `.ship/${SHIP_WORKSPACES_DIR}/{stack}`;
|
|
39572
|
+
var TaskProvider = Literal2("linear", "notion");
|
|
38108
39573
|
var AuthConfig = class extends Class4("AuthConfig")({
|
|
38109
39574
|
apiKey: String$
|
|
38110
39575
|
}) {
|
|
@@ -38115,6 +39580,40 @@ var LinearConfig = class extends Class4("LinearConfig")({
|
|
|
38115
39580
|
projectId: OptionFromNullOr(ProjectId)
|
|
38116
39581
|
}) {
|
|
38117
39582
|
};
|
|
39583
|
+
var NotionPropertyMapping = class extends Class4(
|
|
39584
|
+
"NotionPropertyMapping"
|
|
39585
|
+
)({
|
|
39586
|
+
/** Property name for task title (default: "Name") */
|
|
39587
|
+
title: optionalWith(String$, { default: () => "Name" }),
|
|
39588
|
+
/** Property name for task status (default: "Status") */
|
|
39589
|
+
status: optionalWith(String$, { default: () => "Status" }),
|
|
39590
|
+
/** Property name for task priority (default: "Priority") */
|
|
39591
|
+
priority: optionalWith(String$, { default: () => "Priority" }),
|
|
39592
|
+
/** Property name for task description (default: "Description") */
|
|
39593
|
+
description: optionalWith(String$, { default: () => "Description" }),
|
|
39594
|
+
/** Property name for labels/tags (default: "Labels") */
|
|
39595
|
+
labels: optionalWith(String$, { default: () => "Labels" }),
|
|
39596
|
+
/** Property name for blocked-by relation (default: "Blocked By") */
|
|
39597
|
+
blockedBy: optionalWith(String$, { default: () => "Blocked By" }),
|
|
39598
|
+
/** Property name for task type (default: "Type") */
|
|
39599
|
+
type: optionalWith(String$, { default: () => "Type" }),
|
|
39600
|
+
/** Property name for task identifier (default: "ID") */
|
|
39601
|
+
identifier: optionalWith(String$, { default: () => "ID" }),
|
|
39602
|
+
/** Property name for parent task relation (default: "Parent") */
|
|
39603
|
+
parent: optionalWith(String$, { default: () => "Parent" })
|
|
39604
|
+
}) {
|
|
39605
|
+
};
|
|
39606
|
+
var NotionConfig = class extends Class4("NotionConfig")({
|
|
39607
|
+
/** The Notion database ID to use for tasks */
|
|
39608
|
+
databaseId: String$,
|
|
39609
|
+
/** Optional workspace ID (for multi-workspace setups) */
|
|
39610
|
+
workspaceId: OptionFromNullOr(String$),
|
|
39611
|
+
/** Property mapping configuration */
|
|
39612
|
+
propertyMapping: optionalWith(NotionPropertyMapping, {
|
|
39613
|
+
default: () => new NotionPropertyMapping({})
|
|
39614
|
+
})
|
|
39615
|
+
}) {
|
|
39616
|
+
};
|
|
38118
39617
|
var GitConfig = class extends Class4("GitConfig")({
|
|
38119
39618
|
defaultBranch: optionalWith(String$, { default: () => "main" })
|
|
38120
39619
|
}) {
|
|
@@ -38150,7 +39649,13 @@ var WorkspaceConfig = class extends Class4("WorkspaceConfig")({
|
|
|
38150
39649
|
}) {
|
|
38151
39650
|
};
|
|
38152
39651
|
var ShipConfig = class extends Class4("ShipConfig")({
|
|
39652
|
+
/** Task provider to use (default: "linear" for backward compatibility) */
|
|
39653
|
+
provider: optionalWith(TaskProvider, { default: () => "linear" }),
|
|
39654
|
+
/** Linear configuration (required for "linear" provider, which is default) */
|
|
38153
39655
|
linear: LinearConfig,
|
|
39656
|
+
/** Notion configuration (required when provider is "notion") */
|
|
39657
|
+
notion: OptionFromNullOr(NotionConfig),
|
|
39658
|
+
/** Authentication config */
|
|
38154
39659
|
auth: AuthConfig,
|
|
38155
39660
|
git: optionalWith(GitConfig, { default: () => new GitConfig({}) }),
|
|
38156
39661
|
pr: optionalWith(PrConfig, { default: () => new PrConfig({}) }),
|
|
@@ -38159,7 +39664,13 @@ var ShipConfig = class extends Class4("ShipConfig")({
|
|
|
38159
39664
|
}) {
|
|
38160
39665
|
};
|
|
38161
39666
|
var PartialShipConfig = class extends Class4("PartialShipConfig")({
|
|
39667
|
+
/** Task provider to use (default: "linear" for backward compatibility) */
|
|
39668
|
+
provider: optionalWith(TaskProvider, { default: () => "linear" }),
|
|
39669
|
+
/** Linear configuration (optional during initialization) */
|
|
38162
39670
|
linear: OptionFromNullOr(LinearConfig),
|
|
39671
|
+
/** Notion configuration (optional during initialization) */
|
|
39672
|
+
notion: OptionFromNullOr(NotionConfig),
|
|
39673
|
+
/** Authentication config (optional during initialization) */
|
|
38163
39674
|
auth: OptionFromNullOr(AuthConfig),
|
|
38164
39675
|
git: optionalWith(GitConfig, { default: () => new GitConfig({}) }),
|
|
38165
39676
|
pr: optionalWith(PrConfig, { default: () => new PrConfig({}) }),
|
|
@@ -38167,6 +39678,8 @@ var PartialShipConfig = class extends Class4("PartialShipConfig")({
|
|
|
38167
39678
|
workspace: optionalWith(WorkspaceConfig, { default: () => new WorkspaceConfig({}) })
|
|
38168
39679
|
}) {
|
|
38169
39680
|
};
|
|
39681
|
+
(class extends TaggedError("ConfigValidationError") {
|
|
39682
|
+
});
|
|
38170
39683
|
var WorkspaceMetadata = class extends Class4("WorkspaceMetadata")({
|
|
38171
39684
|
/** Workspace name (matches jj workspace name) */
|
|
38172
39685
|
name: String$,
|
|
@@ -38271,6 +39784,7 @@ var formatApiError = (error4) => pipe(
|
|
|
38271
39784
|
error4,
|
|
38272
39785
|
value4,
|
|
38273
39786
|
tag4("LinearApiError", (e2) => e2.message),
|
|
39787
|
+
tag4("NotionApiError", (e2) => e2.message),
|
|
38274
39788
|
tag4("TaskError", (e2) => e2.message),
|
|
38275
39789
|
exhaustive2
|
|
38276
39790
|
);
|
|
@@ -39506,6 +41020,8 @@ var PromptCancelledError = class _PromptCancelledError extends TaggedError("Prom
|
|
|
39506
41020
|
};
|
|
39507
41021
|
var LinearApiError = class extends TaggedError("LinearApiError") {
|
|
39508
41022
|
};
|
|
41023
|
+
var NotionApiError = class extends TaggedError("NotionApiError") {
|
|
41024
|
+
};
|
|
39509
41025
|
(class extends TaggedError("RateLimitError") {
|
|
39510
41026
|
});
|
|
39511
41027
|
var OpenCodeError = class extends TaggedError("OpenCodeError") {
|
|
@@ -191238,7 +192754,7 @@ var command = ship.pipe(
|
|
|
191238
192754
|
prCommand
|
|
191239
192755
|
])
|
|
191240
192756
|
);
|
|
191241
|
-
var version = "0.1.
|
|
192757
|
+
var version = "0.1.10" ;
|
|
191242
192758
|
var run9 = run8(command, {
|
|
191243
192759
|
name: "ship",
|
|
191244
192760
|
version
|
|
@@ -193100,10 +194616,12 @@ Details: ${e2.message}`,
|
|
|
193100
194616
|
if (!yaml) {
|
|
193101
194617
|
return new PartialShipConfig({
|
|
193102
194618
|
linear: none2(),
|
|
194619
|
+
notion: none2(),
|
|
193103
194620
|
auth: none2()
|
|
193104
194621
|
});
|
|
193105
194622
|
}
|
|
193106
194623
|
return new PartialShipConfig({
|
|
194624
|
+
// provider defaults to "linear" in schema
|
|
193107
194625
|
linear: yaml.linear ? some2(
|
|
193108
194626
|
new LinearConfig({
|
|
193109
194627
|
teamId: asTeamId(yaml.linear.teamId),
|
|
@@ -193111,6 +194629,8 @@ Details: ${e2.message}`,
|
|
|
193111
194629
|
projectId: yaml.linear.projectId ? some2(asProjectId(yaml.linear.projectId)) : none2()
|
|
193112
194630
|
})
|
|
193113
194631
|
) : none2(),
|
|
194632
|
+
notion: none2(),
|
|
194633
|
+
// TODO: Parse notion config from yaml when implemented
|
|
193114
194634
|
auth: yaml.auth ? some2(new AuthConfig({ apiKey: yaml.auth.apiKey })) : none2()
|
|
193115
194635
|
});
|
|
193116
194636
|
};
|
|
@@ -193160,6 +194680,8 @@ Details: ${e2.message}`,
|
|
|
193160
194680
|
teamKey: yaml.linear.teamKey,
|
|
193161
194681
|
projectId: yaml.linear.projectId ? some2(asProjectId(yaml.linear.projectId)) : none2()
|
|
193162
194682
|
}),
|
|
194683
|
+
notion: none2(),
|
|
194684
|
+
// TODO: Parse notion config from yaml when implemented
|
|
193163
194685
|
auth: new AuthConfig({ apiKey: yaml.auth.apiKey }),
|
|
193164
194686
|
git: new GitConfig({ defaultBranch: yaml.git?.defaultBranch ?? "main" }),
|
|
193165
194687
|
pr: new PrConfig({ openBrowser: yaml.pr?.openBrowser ?? true }),
|
|
@@ -195127,7 +196649,7 @@ var make73 = gen2(function* () {
|
|
|
195127
196649
|
}),
|
|
195128
196650
|
"Getting branch name"
|
|
195129
196651
|
);
|
|
195130
|
-
const
|
|
196652
|
+
const SESSION_LABEL_PREFIX2 = "session:";
|
|
195131
196653
|
const setTypeLabel = (id2, type3) => withRetryAndTimeout3(
|
|
195132
196654
|
gen2(function* () {
|
|
195133
196655
|
const client = yield* linearClient.client();
|
|
@@ -195153,11 +196675,11 @@ var make73 = gen2(function* () {
|
|
|
195153
196675
|
try: () => issue.team,
|
|
195154
196676
|
catch: (e2) => new LinearApiError({ message: `Failed to fetch team: ${e2}`, cause: e2 })
|
|
195155
196677
|
});
|
|
195156
|
-
const targetLabelName = `${
|
|
196678
|
+
const targetLabelName = `${SESSION_LABEL_PREFIX2}${sessionId}`;
|
|
195157
196679
|
const allLabels = yield* tryPromise2({
|
|
195158
196680
|
try: () => client.issueLabels({
|
|
195159
196681
|
filter: {
|
|
195160
|
-
name: { startsWith:
|
|
196682
|
+
name: { startsWith: SESSION_LABEL_PREFIX2 }
|
|
195161
196683
|
}
|
|
195162
196684
|
}),
|
|
195163
196685
|
catch: (e2) => new LinearApiError({ message: `Failed to fetch session labels: ${e2}`, cause: e2 })
|
|
@@ -195190,7 +196712,7 @@ var make73 = gen2(function* () {
|
|
|
195190
196712
|
});
|
|
195191
196713
|
targetLabelId = createdLabel.id;
|
|
195192
196714
|
}
|
|
195193
|
-
const currentLabelIds = currentLabels?.nodes?.filter((l2) => !l2.name.startsWith(
|
|
196715
|
+
const currentLabelIds = currentLabels?.nodes?.filter((l2) => !l2.name.startsWith(SESSION_LABEL_PREFIX2)).map((l2) => l2.id) ?? [];
|
|
195194
196716
|
const newLabelIds = [...currentLabelIds, targetLabelId];
|
|
195195
196717
|
const result = yield* tryPromise2({
|
|
195196
196718
|
try: () => client.updateIssue(id2, { labelIds: newLabelIds }),
|
|
@@ -195216,11 +196738,11 @@ var make73 = gen2(function* () {
|
|
|
195216
196738
|
try: () => issue.labels(),
|
|
195217
196739
|
catch: (e2) => new LinearApiError({ message: `Failed to fetch issue labels: ${e2}`, cause: e2 })
|
|
195218
196740
|
});
|
|
195219
|
-
const sessionLabels = currentLabels?.nodes?.filter((l2) => l2.name.startsWith(
|
|
196741
|
+
const sessionLabels = currentLabels?.nodes?.filter((l2) => l2.name.startsWith(SESSION_LABEL_PREFIX2)) ?? [];
|
|
195220
196742
|
if (sessionLabels.length === 0) {
|
|
195221
196743
|
return;
|
|
195222
196744
|
}
|
|
195223
|
-
const nonSessionLabelIds = currentLabels?.nodes?.filter((l2) => !l2.name.startsWith(
|
|
196745
|
+
const nonSessionLabelIds = currentLabels?.nodes?.filter((l2) => !l2.name.startsWith(SESSION_LABEL_PREFIX2)).map((l2) => l2.id) ?? [];
|
|
195224
196746
|
const result = yield* tryPromise2({
|
|
195225
196747
|
try: () => client.updateIssue(id2, { labelIds: nonSessionLabelIds }),
|
|
195226
196748
|
catch: (e2) => new LinearApiError({ message: `Failed to update issue labels: ${e2}`, cause: e2 })
|
|
@@ -195473,6 +196995,824 @@ var make74 = gen2(function* () {
|
|
|
195473
196995
|
});
|
|
195474
196996
|
var MilestoneRepositoryLive = effect(MilestoneRepository, make74);
|
|
195475
196997
|
|
|
196998
|
+
// src/adapters/driven/notion/NotionClient.ts
|
|
196999
|
+
var import_client = __toESM(require_src2());
|
|
197000
|
+
var NotionClientService = GenericTag(
|
|
197001
|
+
"NotionClientService"
|
|
197002
|
+
);
|
|
197003
|
+
intersect6(
|
|
197004
|
+
exponential3(millis(500)),
|
|
197005
|
+
// Start with 500ms, double each time
|
|
197006
|
+
recurs2(3)
|
|
197007
|
+
// Max 3 retries
|
|
197008
|
+
).pipe(
|
|
197009
|
+
whileInput2((error4) => error4.statusCode === 429)
|
|
197010
|
+
);
|
|
197011
|
+
var NOTION_DEFAULT_TIMEOUT = seconds(30);
|
|
197012
|
+
var make75 = gen2(function* () {
|
|
197013
|
+
const auth = yield* AuthService;
|
|
197014
|
+
const createClient = gen2(function* () {
|
|
197015
|
+
const apiKey = yield* auth.getApiKey().pipe(
|
|
197016
|
+
mapError2(
|
|
197017
|
+
(e2) => new NotionApiError({
|
|
197018
|
+
message: `Authentication required: ${e2.message}`
|
|
197019
|
+
})
|
|
197020
|
+
)
|
|
197021
|
+
);
|
|
197022
|
+
return new import_client.Client({
|
|
197023
|
+
auth: apiKey,
|
|
197024
|
+
timeoutMs: toMillis(NOTION_DEFAULT_TIMEOUT)
|
|
197025
|
+
});
|
|
197026
|
+
});
|
|
197027
|
+
const cachedClient = yield* cached3(createClient);
|
|
197028
|
+
return { client: () => cachedClient };
|
|
197029
|
+
});
|
|
197030
|
+
var NotionClientLive = effect(NotionClientService, make75);
|
|
197031
|
+
|
|
197032
|
+
// src/adapters/driven/notion/TeamRepositoryNotion.ts
|
|
197033
|
+
var NOTION_TEAM_ID = "notion-workspace";
|
|
197034
|
+
var NOTION_TEAM_KEY = "NOTION";
|
|
197035
|
+
var make76 = gen2(function* () {
|
|
197036
|
+
const notionClientService = yield* NotionClientService;
|
|
197037
|
+
const getClient = () => notionClientService.client();
|
|
197038
|
+
const getWorkspaceTeam = () => gen2(function* () {
|
|
197039
|
+
const client = yield* getClient();
|
|
197040
|
+
const botUser = yield* tryPromise2({
|
|
197041
|
+
try: () => client.users.me({}),
|
|
197042
|
+
catch: (e2) => new NotionApiError({ message: `Failed to fetch bot user: ${e2}`, cause: e2 })
|
|
197043
|
+
});
|
|
197044
|
+
let workspaceName = "Notion Workspace";
|
|
197045
|
+
if (botUser.type === "bot" && botUser.bot && typeof botUser.bot === "object" && "owner" in botUser.bot) {
|
|
197046
|
+
const owner = botUser.bot.owner;
|
|
197047
|
+
if (owner.type === "workspace") {
|
|
197048
|
+
workspaceName = "Notion Workspace";
|
|
197049
|
+
} else if (owner.type === "user" && "user" in owner && owner.user && "name" in owner.user && owner.user.name) {
|
|
197050
|
+
workspaceName = `${owner.user.name}'s Workspace`;
|
|
197051
|
+
}
|
|
197052
|
+
}
|
|
197053
|
+
if (botUser.name) {
|
|
197054
|
+
workspaceName = `${botUser.name} Workspace`;
|
|
197055
|
+
}
|
|
197056
|
+
return new Team({
|
|
197057
|
+
id: NOTION_TEAM_ID,
|
|
197058
|
+
name: workspaceName,
|
|
197059
|
+
key: NOTION_TEAM_KEY
|
|
197060
|
+
});
|
|
197061
|
+
});
|
|
197062
|
+
const getTeams = () => gen2(function* () {
|
|
197063
|
+
const team = yield* getWorkspaceTeam();
|
|
197064
|
+
return [team];
|
|
197065
|
+
});
|
|
197066
|
+
const getTeam = (id2) => gen2(function* () {
|
|
197067
|
+
if (id2 !== NOTION_TEAM_ID && id2 !== "notion" && id2 !== "default") {
|
|
197068
|
+
return yield* fail7(new TeamNotFoundError({ teamId: id2 }));
|
|
197069
|
+
}
|
|
197070
|
+
return yield* getWorkspaceTeam();
|
|
197071
|
+
});
|
|
197072
|
+
const createTeam = (_input) => (
|
|
197073
|
+
// Notion doesn't support creating teams/workspaces via API
|
|
197074
|
+
fail7(
|
|
197075
|
+
new TaskError({
|
|
197076
|
+
message: "Creating teams is not supported in Notion. Notion integrations operate within a single workspace."
|
|
197077
|
+
})
|
|
197078
|
+
)
|
|
197079
|
+
);
|
|
197080
|
+
return {
|
|
197081
|
+
getTeams,
|
|
197082
|
+
getTeam,
|
|
197083
|
+
createTeam
|
|
197084
|
+
};
|
|
197085
|
+
});
|
|
197086
|
+
var TeamRepositoryNotion = effect(TeamRepository, make76);
|
|
197087
|
+
|
|
197088
|
+
// src/adapters/driven/notion/ProjectRepositoryNotion.ts
|
|
197089
|
+
var extractPlainText = (richText) => richText.map((rt) => rt.plain_text).join("");
|
|
197090
|
+
var mapDataSourceToProject = (dataSource, teamId) => new Project({
|
|
197091
|
+
id: dataSource.id,
|
|
197092
|
+
name: extractPlainText(dataSource.title) || "Untitled Database",
|
|
197093
|
+
teamId
|
|
197094
|
+
});
|
|
197095
|
+
var isDataSource = (result) => result.object === "data_source" && "title" in result;
|
|
197096
|
+
var make77 = gen2(function* () {
|
|
197097
|
+
const notionClientService = yield* NotionClientService;
|
|
197098
|
+
const getClient = () => notionClientService.client();
|
|
197099
|
+
const getProjects = (_teamId) => gen2(function* () {
|
|
197100
|
+
const client = yield* getClient();
|
|
197101
|
+
const response = yield* tryPromise2({
|
|
197102
|
+
try: () => client.search({
|
|
197103
|
+
filter: {
|
|
197104
|
+
property: "object",
|
|
197105
|
+
value: "data_source"
|
|
197106
|
+
},
|
|
197107
|
+
page_size: 100
|
|
197108
|
+
}),
|
|
197109
|
+
catch: (e2) => new NotionApiError({ message: `Failed to search databases: ${e2}`, cause: e2 })
|
|
197110
|
+
});
|
|
197111
|
+
const dataSources = response.results.filter(isDataSource);
|
|
197112
|
+
return dataSources.map((ds) => mapDataSourceToProject(ds, NOTION_TEAM_ID));
|
|
197113
|
+
});
|
|
197114
|
+
const createProject = (_teamId, _input) => (
|
|
197115
|
+
// Creating databases in Notion requires a parent page, which is more complex
|
|
197116
|
+
// than what our simple CreateProjectInput supports. For now, fail with an error.
|
|
197117
|
+
// Users should create databases directly in Notion and share them with the integration.
|
|
197118
|
+
fail7(
|
|
197119
|
+
new TaskError({
|
|
197120
|
+
message: "Creating projects (databases) is not supported via ship-cli for Notion. Please create databases directly in Notion and share them with your integration."
|
|
197121
|
+
})
|
|
197122
|
+
)
|
|
197123
|
+
);
|
|
197124
|
+
return {
|
|
197125
|
+
getProjects,
|
|
197126
|
+
createProject
|
|
197127
|
+
};
|
|
197128
|
+
});
|
|
197129
|
+
var ProjectRepositoryNotion = effect(ProjectRepository, make77);
|
|
197130
|
+
|
|
197131
|
+
// src/adapters/driven/notion/NotionMapper.ts
|
|
197132
|
+
new NotionPropertyMapping({});
|
|
197133
|
+
var getProperty = (page, propertyName) => {
|
|
197134
|
+
return page.properties[propertyName];
|
|
197135
|
+
};
|
|
197136
|
+
var extractRichText = (richText) => {
|
|
197137
|
+
return richText.map((item) => item.plain_text).join("");
|
|
197138
|
+
};
|
|
197139
|
+
var extractTitle = (property) => {
|
|
197140
|
+
if (!property || property.type !== "title") {
|
|
197141
|
+
return "";
|
|
197142
|
+
}
|
|
197143
|
+
return extractRichText(property.title);
|
|
197144
|
+
};
|
|
197145
|
+
var extractText = (property) => {
|
|
197146
|
+
if (!property || property.type !== "rich_text") {
|
|
197147
|
+
return void 0;
|
|
197148
|
+
}
|
|
197149
|
+
const text12 = extractRichText(property.rich_text);
|
|
197150
|
+
return text12 || void 0;
|
|
197151
|
+
};
|
|
197152
|
+
var extractStatus = (property) => {
|
|
197153
|
+
if (!property || property.type !== "status") {
|
|
197154
|
+
return void 0;
|
|
197155
|
+
}
|
|
197156
|
+
return property.status?.name;
|
|
197157
|
+
};
|
|
197158
|
+
var extractSelect = (property) => {
|
|
197159
|
+
if (!property || property.type !== "select") {
|
|
197160
|
+
return void 0;
|
|
197161
|
+
}
|
|
197162
|
+
return property.select?.name;
|
|
197163
|
+
};
|
|
197164
|
+
var extractMultiSelect = (property) => {
|
|
197165
|
+
if (!property || property.type !== "multi_select") {
|
|
197166
|
+
return [];
|
|
197167
|
+
}
|
|
197168
|
+
return property.multi_select.map((item) => item.name);
|
|
197169
|
+
};
|
|
197170
|
+
var extractRelation = (property) => {
|
|
197171
|
+
if (!property || property.type !== "relation") {
|
|
197172
|
+
return [];
|
|
197173
|
+
}
|
|
197174
|
+
return property.relation.map((item) => item.id);
|
|
197175
|
+
};
|
|
197176
|
+
var extractFormula = (property) => {
|
|
197177
|
+
if (!property || property.type !== "formula") {
|
|
197178
|
+
return void 0;
|
|
197179
|
+
}
|
|
197180
|
+
const formula = property.formula;
|
|
197181
|
+
switch (formula.type) {
|
|
197182
|
+
case "string":
|
|
197183
|
+
return formula.string ?? void 0;
|
|
197184
|
+
case "number":
|
|
197185
|
+
return formula.number?.toString();
|
|
197186
|
+
case "boolean":
|
|
197187
|
+
return formula.boolean?.toString();
|
|
197188
|
+
case "date":
|
|
197189
|
+
return formula.date?.start;
|
|
197190
|
+
default:
|
|
197191
|
+
return void 0;
|
|
197192
|
+
}
|
|
197193
|
+
};
|
|
197194
|
+
var extractUniqueId = (property) => {
|
|
197195
|
+
if (!property || property.type !== "unique_id") {
|
|
197196
|
+
return void 0;
|
|
197197
|
+
}
|
|
197198
|
+
const prefix = property.unique_id.prefix ?? "";
|
|
197199
|
+
const number5 = property.unique_id.number;
|
|
197200
|
+
return number5 !== null ? `${prefix}${number5}` : void 0;
|
|
197201
|
+
};
|
|
197202
|
+
var mapStatusToStateType = (status2) => {
|
|
197203
|
+
if (!status2) return "unstarted";
|
|
197204
|
+
const normalized = status2.toLowerCase().trim();
|
|
197205
|
+
if (normalized.includes("backlog") || normalized.includes("icebox") || normalized.includes("later")) {
|
|
197206
|
+
return "backlog";
|
|
197207
|
+
}
|
|
197208
|
+
if (normalized.includes("done") || normalized.includes("complete") || normalized.includes("shipped") || normalized.includes("released") || normalized.includes("resolved")) {
|
|
197209
|
+
return "completed";
|
|
197210
|
+
}
|
|
197211
|
+
if (normalized.includes("cancel") || normalized.includes("won't") || normalized.includes("wont") || normalized.includes("duplicate") || normalized.includes("archived")) {
|
|
197212
|
+
return "canceled";
|
|
197213
|
+
}
|
|
197214
|
+
if (normalized.includes("progress") || normalized.includes("doing") || normalized.includes("active") || normalized.includes("review") || normalized.includes("testing") || normalized.includes("started")) {
|
|
197215
|
+
return "started";
|
|
197216
|
+
}
|
|
197217
|
+
return "unstarted";
|
|
197218
|
+
};
|
|
197219
|
+
var mapStatusToWorkflowState = (status2) => {
|
|
197220
|
+
return new WorkflowState({
|
|
197221
|
+
id: status2 ?? "unknown",
|
|
197222
|
+
name: status2 ?? "Unknown",
|
|
197223
|
+
type: mapStatusToStateType(status2)
|
|
197224
|
+
});
|
|
197225
|
+
};
|
|
197226
|
+
var mapPriority2 = (priority) => {
|
|
197227
|
+
if (!priority) return "none";
|
|
197228
|
+
const normalized = priority.toLowerCase().trim();
|
|
197229
|
+
if (normalized.includes("urgent") || normalized.includes("critical") || normalized === "p0") {
|
|
197230
|
+
return "urgent";
|
|
197231
|
+
}
|
|
197232
|
+
if (normalized.includes("high") || normalized === "p1") {
|
|
197233
|
+
return "high";
|
|
197234
|
+
}
|
|
197235
|
+
if (normalized.includes("medium") || normalized.includes("normal") || normalized === "p2") {
|
|
197236
|
+
return "medium";
|
|
197237
|
+
}
|
|
197238
|
+
if (normalized.includes("low") || normalized === "p3" || normalized === "p4") {
|
|
197239
|
+
return "low";
|
|
197240
|
+
}
|
|
197241
|
+
return "none";
|
|
197242
|
+
};
|
|
197243
|
+
var priorityToNotion = (priority) => {
|
|
197244
|
+
switch (priority) {
|
|
197245
|
+
case "urgent":
|
|
197246
|
+
return "Urgent";
|
|
197247
|
+
case "high":
|
|
197248
|
+
return "High";
|
|
197249
|
+
case "medium":
|
|
197250
|
+
return "Medium";
|
|
197251
|
+
case "low":
|
|
197252
|
+
return "Low";
|
|
197253
|
+
case "none":
|
|
197254
|
+
return "None";
|
|
197255
|
+
}
|
|
197256
|
+
};
|
|
197257
|
+
var mapTaskType = (type3) => {
|
|
197258
|
+
if (!type3) return none2();
|
|
197259
|
+
const normalized = type3.toLowerCase().trim();
|
|
197260
|
+
if (normalized.includes("bug") || normalized.includes("defect")) {
|
|
197261
|
+
return some2("bug");
|
|
197262
|
+
}
|
|
197263
|
+
if (normalized.includes("feature") || normalized.includes("enhancement")) {
|
|
197264
|
+
return some2("feature");
|
|
197265
|
+
}
|
|
197266
|
+
if (normalized.includes("epic")) {
|
|
197267
|
+
return some2("epic");
|
|
197268
|
+
}
|
|
197269
|
+
if (normalized.includes("chore") || normalized.includes("maintenance")) {
|
|
197270
|
+
return some2("chore");
|
|
197271
|
+
}
|
|
197272
|
+
if (normalized.includes("task")) {
|
|
197273
|
+
return some2("task");
|
|
197274
|
+
}
|
|
197275
|
+
return none2();
|
|
197276
|
+
};
|
|
197277
|
+
var generateIdentifier = (page, propertyMapping) => {
|
|
197278
|
+
const idProperty = getProperty(page, propertyMapping.identifier);
|
|
197279
|
+
const uniqueId = extractUniqueId(idProperty);
|
|
197280
|
+
if (uniqueId) return uniqueId;
|
|
197281
|
+
const formulaId = extractFormula(idProperty);
|
|
197282
|
+
if (formulaId) return formulaId;
|
|
197283
|
+
const textId = extractText(idProperty);
|
|
197284
|
+
if (textId) return textId;
|
|
197285
|
+
return `N-${page.id.slice(0, 8)}`;
|
|
197286
|
+
};
|
|
197287
|
+
var mapPageToTask = (page, config2) => {
|
|
197288
|
+
const { propertyMapping, teamId, databaseId } = config2;
|
|
197289
|
+
const title = extractTitle(getProperty(page, propertyMapping.title));
|
|
197290
|
+
const description = extractText(getProperty(page, propertyMapping.description));
|
|
197291
|
+
const status2 = extractStatus(getProperty(page, propertyMapping.status));
|
|
197292
|
+
const priority = extractSelect(getProperty(page, propertyMapping.priority));
|
|
197293
|
+
const type3 = extractSelect(getProperty(page, propertyMapping.type));
|
|
197294
|
+
const labels = extractMultiSelect(getProperty(page, propertyMapping.labels));
|
|
197295
|
+
const blockedByIds = extractRelation(getProperty(page, propertyMapping.blockedBy));
|
|
197296
|
+
const identifier2 = generateIdentifier(page, propertyMapping);
|
|
197297
|
+
const url2 = page.url || `https://notion.so/${page.id.replace(/-/g, "")}`;
|
|
197298
|
+
return new Task({
|
|
197299
|
+
id: page.id,
|
|
197300
|
+
identifier: identifier2,
|
|
197301
|
+
title: title || "Untitled",
|
|
197302
|
+
description: description ? some2(description) : none2(),
|
|
197303
|
+
state: mapStatusToWorkflowState(status2),
|
|
197304
|
+
priority: mapPriority2(priority),
|
|
197305
|
+
type: mapTaskType(type3),
|
|
197306
|
+
teamId,
|
|
197307
|
+
projectId: some2(databaseId),
|
|
197308
|
+
// Use database ID as project
|
|
197309
|
+
milestoneId: none2(),
|
|
197310
|
+
// Notion doesn't have milestones concept
|
|
197311
|
+
milestoneName: none2(),
|
|
197312
|
+
branchName: none2(),
|
|
197313
|
+
// Could be extracted from a custom property
|
|
197314
|
+
url: url2,
|
|
197315
|
+
labels,
|
|
197316
|
+
blockedBy: blockedByIds,
|
|
197317
|
+
blocks: [],
|
|
197318
|
+
// Would need reverse lookup
|
|
197319
|
+
subtasks: [],
|
|
197320
|
+
// Would need separate query for child pages
|
|
197321
|
+
createdAt: new Date(page.created_time),
|
|
197322
|
+
updatedAt: new Date(page.last_edited_time)
|
|
197323
|
+
});
|
|
197324
|
+
};
|
|
197325
|
+
|
|
197326
|
+
// src/adapters/driven/notion/IssueRepositoryNotion.ts
|
|
197327
|
+
var SESSION_LABEL_PREFIX = "session:";
|
|
197328
|
+
var TYPE_LABEL_PREFIX2 = "type:";
|
|
197329
|
+
var titleProperty = (content) => ({
|
|
197330
|
+
title: [{ text: { content } }]
|
|
197331
|
+
});
|
|
197332
|
+
var richTextProperty = (content) => ({
|
|
197333
|
+
rich_text: [{ text: { content } }]
|
|
197334
|
+
});
|
|
197335
|
+
var selectProperty = (name) => ({
|
|
197336
|
+
select: { name }
|
|
197337
|
+
});
|
|
197338
|
+
var multiSelectProperty = (names) => ({
|
|
197339
|
+
multi_select: names.map((name) => ({ name }))
|
|
197340
|
+
});
|
|
197341
|
+
var statusProperty = (name) => ({
|
|
197342
|
+
status: { name }
|
|
197343
|
+
});
|
|
197344
|
+
var relationProperty = (ids3) => ({
|
|
197345
|
+
relation: ids3.map((id2) => ({ id: id2 }))
|
|
197346
|
+
});
|
|
197347
|
+
var isPageObjectResponse = (page) => page !== null && typeof page === "object" && "object" in page && page.object === "page" && "properties" in page;
|
|
197348
|
+
var extractStatusCode = (error4) => {
|
|
197349
|
+
if (error4 && typeof error4 === "object") {
|
|
197350
|
+
if ("status" in error4 && typeof error4.status === "number") {
|
|
197351
|
+
return error4.status;
|
|
197352
|
+
}
|
|
197353
|
+
if ("statusCode" in error4 && typeof error4.statusCode === "number") {
|
|
197354
|
+
return error4.statusCode;
|
|
197355
|
+
}
|
|
197356
|
+
}
|
|
197357
|
+
return void 0;
|
|
197358
|
+
};
|
|
197359
|
+
var toNotionApiError = (message, cause2) => {
|
|
197360
|
+
const statusCode = extractStatusCode(cause2);
|
|
197361
|
+
return statusCode !== void 0 ? new NotionApiError({ message, statusCode, cause: cause2 }) : new NotionApiError({ message, cause: cause2 });
|
|
197362
|
+
};
|
|
197363
|
+
var getNotionConfig = (configRepo) => gen2(function* () {
|
|
197364
|
+
const config2 = yield* configRepo.load().pipe(
|
|
197365
|
+
mapError2(
|
|
197366
|
+
(e2) => new NotionApiError({ message: `Failed to load config: ${e2.message}`, cause: e2 })
|
|
197367
|
+
)
|
|
197368
|
+
);
|
|
197369
|
+
if (isNone2(config2.notion)) {
|
|
197370
|
+
return yield* fail7(
|
|
197371
|
+
new NotionApiError({ message: "Notion configuration not found. Run 'ship init' to configure." })
|
|
197372
|
+
);
|
|
197373
|
+
}
|
|
197374
|
+
return getOrThrow2(config2.notion);
|
|
197375
|
+
});
|
|
197376
|
+
var createMapConfig = (notionConfig, teamId) => ({
|
|
197377
|
+
propertyMapping: notionConfig.propertyMapping,
|
|
197378
|
+
teamId,
|
|
197379
|
+
databaseId: notionConfig.databaseId
|
|
197380
|
+
});
|
|
197381
|
+
var isPageBlocked = (page, propertyMapping, allPages) => {
|
|
197382
|
+
const blockedByIds = extractRelation(page.properties[propertyMapping.blockedBy]);
|
|
197383
|
+
if (blockedByIds.length === 0) return false;
|
|
197384
|
+
for (const blockerId of blockedByIds) {
|
|
197385
|
+
const blockerPage = allPages.find((p4) => p4.id === blockerId);
|
|
197386
|
+
if (blockerPage) {
|
|
197387
|
+
const status2 = blockerPage.properties[propertyMapping.status];
|
|
197388
|
+
if (status2 && status2.type === "status" && status2.status) {
|
|
197389
|
+
const stateType = mapStatusToStateType(status2.status.name);
|
|
197390
|
+
if (stateType !== "completed" && stateType !== "canceled") {
|
|
197391
|
+
return true;
|
|
197392
|
+
}
|
|
197393
|
+
}
|
|
197394
|
+
}
|
|
197395
|
+
}
|
|
197396
|
+
return false;
|
|
197397
|
+
};
|
|
197398
|
+
var handleNotFoundError = (taskId) => (e2) => {
|
|
197399
|
+
if (e2.statusCode === 404) {
|
|
197400
|
+
return fail7(new TaskNotFoundError({ taskId }));
|
|
197401
|
+
}
|
|
197402
|
+
return fail7(e2);
|
|
197403
|
+
};
|
|
197404
|
+
var queryDataSource = (client, databaseId, filter12, pageSize = 100) => tryPromise2({
|
|
197405
|
+
try: () => {
|
|
197406
|
+
const params = {
|
|
197407
|
+
data_source_id: databaseId,
|
|
197408
|
+
page_size: pageSize
|
|
197409
|
+
};
|
|
197410
|
+
if (filter12 !== void 0) {
|
|
197411
|
+
params.filter = filter12;
|
|
197412
|
+
}
|
|
197413
|
+
return client.dataSources.query(params);
|
|
197414
|
+
},
|
|
197415
|
+
catch: (e2) => toNotionApiError(`Failed to query database: ${e2}`, e2)
|
|
197416
|
+
});
|
|
197417
|
+
var extractPages = (response) => response.results.filter(
|
|
197418
|
+
(r2) => "properties" in r2 && r2.object === "page"
|
|
197419
|
+
);
|
|
197420
|
+
var make78 = gen2(function* () {
|
|
197421
|
+
const configRepo = yield* ConfigRepository;
|
|
197422
|
+
const notionClientService = yield* NotionClientService;
|
|
197423
|
+
const getClient = () => notionClientService.client();
|
|
197424
|
+
const teamId = "notion";
|
|
197425
|
+
const getTask = (id2) => gen2(function* () {
|
|
197426
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197427
|
+
const client = yield* getClient();
|
|
197428
|
+
const page = yield* tryPromise2({
|
|
197429
|
+
try: () => client.pages.retrieve({ page_id: id2 }),
|
|
197430
|
+
catch: (e2) => toNotionApiError(`Failed to fetch page: ${e2}`, e2)
|
|
197431
|
+
}).pipe(catchAll2(handleNotFoundError(id2)));
|
|
197432
|
+
if (!isPageObjectResponse(page)) {
|
|
197433
|
+
return yield* fail7(new TaskNotFoundError({ taskId: id2 }));
|
|
197434
|
+
}
|
|
197435
|
+
return mapPageToTask(page, createMapConfig(notionConfig, teamId));
|
|
197436
|
+
});
|
|
197437
|
+
const getTaskByIdentifier = (identifier2) => gen2(function* () {
|
|
197438
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197439
|
+
const { propertyMapping, databaseId } = notionConfig;
|
|
197440
|
+
const client = yield* getClient();
|
|
197441
|
+
const response = yield* queryDataSource(client, databaseId, {
|
|
197442
|
+
or: [
|
|
197443
|
+
// Try to match by ID property (if it's a rich_text)
|
|
197444
|
+
{
|
|
197445
|
+
property: propertyMapping.identifier,
|
|
197446
|
+
rich_text: { equals: identifier2 }
|
|
197447
|
+
},
|
|
197448
|
+
// Try to match by title
|
|
197449
|
+
{
|
|
197450
|
+
property: propertyMapping.title,
|
|
197451
|
+
title: { equals: identifier2 }
|
|
197452
|
+
}
|
|
197453
|
+
]
|
|
197454
|
+
}, 1);
|
|
197455
|
+
const pages = extractPages(response);
|
|
197456
|
+
const page = pages[0];
|
|
197457
|
+
if (!page) {
|
|
197458
|
+
return yield* fail7(new TaskNotFoundError({ taskId: identifier2 }));
|
|
197459
|
+
}
|
|
197460
|
+
return mapPageToTask(page, createMapConfig(notionConfig, teamId));
|
|
197461
|
+
});
|
|
197462
|
+
const createTask = (_teamId, input) => gen2(function* () {
|
|
197463
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197464
|
+
const { propertyMapping, databaseId } = notionConfig;
|
|
197465
|
+
const client = yield* getClient();
|
|
197466
|
+
const properties = {
|
|
197467
|
+
[propertyMapping.title]: titleProperty(input.title),
|
|
197468
|
+
[propertyMapping.priority]: selectProperty(priorityToNotion(input.priority)),
|
|
197469
|
+
[propertyMapping.labels]: multiSelectProperty([`${TYPE_LABEL_PREFIX2}${input.type}`])
|
|
197470
|
+
};
|
|
197471
|
+
if (isSome2(input.description)) {
|
|
197472
|
+
properties[propertyMapping.description] = richTextProperty(input.description.value);
|
|
197473
|
+
}
|
|
197474
|
+
const page = yield* tryPromise2({
|
|
197475
|
+
try: () => client.pages.create({
|
|
197476
|
+
parent: { database_id: databaseId },
|
|
197477
|
+
properties
|
|
197478
|
+
}),
|
|
197479
|
+
catch: (e2) => toNotionApiError(`Failed to create page: ${e2}`, e2)
|
|
197480
|
+
}).pipe(
|
|
197481
|
+
mapError2((e2) => new TaskError({ message: `Failed to create task: ${e2.message}`, cause: e2 }))
|
|
197482
|
+
);
|
|
197483
|
+
if (!isPageObjectResponse(page)) {
|
|
197484
|
+
return yield* fail7(new TaskError({ message: "Failed to create task: unexpected response" }));
|
|
197485
|
+
}
|
|
197486
|
+
return mapPageToTask(page, createMapConfig(notionConfig, teamId));
|
|
197487
|
+
});
|
|
197488
|
+
const updateTask = (id2, input) => gen2(function* () {
|
|
197489
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197490
|
+
const { propertyMapping } = notionConfig;
|
|
197491
|
+
const client = yield* getClient();
|
|
197492
|
+
const updateProps = {};
|
|
197493
|
+
if (isSome2(input.title)) {
|
|
197494
|
+
updateProps[propertyMapping.title] = titleProperty(input.title.value);
|
|
197495
|
+
}
|
|
197496
|
+
if (isSome2(input.description)) {
|
|
197497
|
+
updateProps[propertyMapping.description] = richTextProperty(input.description.value);
|
|
197498
|
+
}
|
|
197499
|
+
if (isSome2(input.status)) {
|
|
197500
|
+
const statusMap = {
|
|
197501
|
+
backlog: "Backlog",
|
|
197502
|
+
todo: "To Do",
|
|
197503
|
+
in_progress: "In Progress",
|
|
197504
|
+
in_review: "In Review",
|
|
197505
|
+
done: "Done",
|
|
197506
|
+
cancelled: "Cancelled"
|
|
197507
|
+
};
|
|
197508
|
+
updateProps[propertyMapping.status] = statusProperty(
|
|
197509
|
+
statusMap[input.status.value] ?? input.status.value
|
|
197510
|
+
);
|
|
197511
|
+
}
|
|
197512
|
+
if (isSome2(input.priority)) {
|
|
197513
|
+
updateProps[propertyMapping.priority] = selectProperty(priorityToNotion(input.priority.value));
|
|
197514
|
+
}
|
|
197515
|
+
const page = yield* tryPromise2({
|
|
197516
|
+
try: () => client.pages.update({
|
|
197517
|
+
page_id: id2,
|
|
197518
|
+
properties: updateProps
|
|
197519
|
+
}),
|
|
197520
|
+
catch: (e2) => toNotionApiError(`Failed to update page: ${e2}`, e2)
|
|
197521
|
+
}).pipe(
|
|
197522
|
+
catchAll2((e2) => {
|
|
197523
|
+
if (e2.statusCode === 404) {
|
|
197524
|
+
return fail7(new TaskNotFoundError({ taskId: id2 }));
|
|
197525
|
+
}
|
|
197526
|
+
return fail7(new TaskError({ message: `Failed to update task: ${e2.message}`, cause: e2 }));
|
|
197527
|
+
})
|
|
197528
|
+
);
|
|
197529
|
+
if (!isPageObjectResponse(page)) {
|
|
197530
|
+
return yield* fail7(new TaskError({ message: "Failed to update task: unexpected response" }));
|
|
197531
|
+
}
|
|
197532
|
+
return mapPageToTask(page, createMapConfig(notionConfig, teamId));
|
|
197533
|
+
});
|
|
197534
|
+
const listTasks = (_teamId, filter12) => gen2(function* () {
|
|
197535
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197536
|
+
const { propertyMapping, databaseId } = notionConfig;
|
|
197537
|
+
const client = yield* getClient();
|
|
197538
|
+
const conditions = [];
|
|
197539
|
+
if (isSome2(filter12.status)) {
|
|
197540
|
+
const statusMap = {
|
|
197541
|
+
backlog: "Backlog",
|
|
197542
|
+
todo: "To Do",
|
|
197543
|
+
in_progress: "In Progress",
|
|
197544
|
+
in_review: "In Review",
|
|
197545
|
+
done: "Done",
|
|
197546
|
+
cancelled: "Cancelled"
|
|
197547
|
+
};
|
|
197548
|
+
conditions.push({
|
|
197549
|
+
property: propertyMapping.status,
|
|
197550
|
+
status: { equals: statusMap[filter12.status.value] ?? filter12.status.value }
|
|
197551
|
+
});
|
|
197552
|
+
} else if (!filter12.includeCompleted) {
|
|
197553
|
+
conditions.push({
|
|
197554
|
+
property: propertyMapping.status,
|
|
197555
|
+
status: { does_not_equal: "Done" }
|
|
197556
|
+
});
|
|
197557
|
+
conditions.push({
|
|
197558
|
+
property: propertyMapping.status,
|
|
197559
|
+
status: { does_not_equal: "Cancelled" }
|
|
197560
|
+
});
|
|
197561
|
+
}
|
|
197562
|
+
if (isSome2(filter12.priority)) {
|
|
197563
|
+
conditions.push({
|
|
197564
|
+
property: propertyMapping.priority,
|
|
197565
|
+
select: { equals: priorityToNotion(filter12.priority.value) }
|
|
197566
|
+
});
|
|
197567
|
+
}
|
|
197568
|
+
const queryFilter = conditions.length > 0 ? { and: conditions } : void 0;
|
|
197569
|
+
const response = yield* queryDataSource(client, databaseId, queryFilter);
|
|
197570
|
+
const pages = extractPages(response);
|
|
197571
|
+
return pages.map(
|
|
197572
|
+
(page) => mapPageToTask(page, createMapConfig(notionConfig, teamId))
|
|
197573
|
+
);
|
|
197574
|
+
});
|
|
197575
|
+
const getReadyTasks = (_teamId, _projectId) => gen2(function* () {
|
|
197576
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197577
|
+
const { propertyMapping, databaseId } = notionConfig;
|
|
197578
|
+
const client = yield* getClient();
|
|
197579
|
+
const response = yield* queryDataSource(client, databaseId, {
|
|
197580
|
+
and: [
|
|
197581
|
+
{ property: propertyMapping.status, status: { does_not_equal: "Done" } },
|
|
197582
|
+
{ property: propertyMapping.status, status: { does_not_equal: "Cancelled" } }
|
|
197583
|
+
]
|
|
197584
|
+
});
|
|
197585
|
+
const pages = extractPages(response);
|
|
197586
|
+
const readyPages = pages.filter(
|
|
197587
|
+
(page) => !isPageBlocked(page, propertyMapping, pages)
|
|
197588
|
+
);
|
|
197589
|
+
return readyPages.map(
|
|
197590
|
+
(page) => mapPageToTask(page, createMapConfig(notionConfig, teamId))
|
|
197591
|
+
);
|
|
197592
|
+
});
|
|
197593
|
+
const getBlockedTasks = (_teamId, _projectId) => gen2(function* () {
|
|
197594
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197595
|
+
const { propertyMapping, databaseId } = notionConfig;
|
|
197596
|
+
const client = yield* getClient();
|
|
197597
|
+
const response = yield* queryDataSource(client, databaseId, {
|
|
197598
|
+
and: [
|
|
197599
|
+
{ property: propertyMapping.status, status: { does_not_equal: "Done" } },
|
|
197600
|
+
{ property: propertyMapping.status, status: { does_not_equal: "Cancelled" } }
|
|
197601
|
+
]
|
|
197602
|
+
});
|
|
197603
|
+
const pages = extractPages(response);
|
|
197604
|
+
const blockedPages = pages.filter(
|
|
197605
|
+
(page) => isPageBlocked(page, propertyMapping, pages)
|
|
197606
|
+
);
|
|
197607
|
+
return blockedPages.map(
|
|
197608
|
+
(page) => mapPageToTask(page, createMapConfig(notionConfig, teamId))
|
|
197609
|
+
);
|
|
197610
|
+
});
|
|
197611
|
+
const addBlocker = (blockedId, blockerId) => gen2(function* () {
|
|
197612
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197613
|
+
const { propertyMapping } = notionConfig;
|
|
197614
|
+
const client = yield* getClient();
|
|
197615
|
+
const page = yield* tryPromise2({
|
|
197616
|
+
try: () => client.pages.retrieve({ page_id: blockedId }),
|
|
197617
|
+
catch: (e2) => toNotionApiError(`Failed to fetch page: ${e2}`, e2)
|
|
197618
|
+
}).pipe(catchAll2(handleNotFoundError(blockedId)));
|
|
197619
|
+
if (!isPageObjectResponse(page)) {
|
|
197620
|
+
return yield* fail7(new TaskNotFoundError({ taskId: blockedId }));
|
|
197621
|
+
}
|
|
197622
|
+
const currentBlockers = extractRelation(
|
|
197623
|
+
page.properties[propertyMapping.blockedBy]
|
|
197624
|
+
);
|
|
197625
|
+
if (currentBlockers.includes(blockerId)) {
|
|
197626
|
+
return;
|
|
197627
|
+
}
|
|
197628
|
+
const newBlockers = [...currentBlockers, blockerId];
|
|
197629
|
+
yield* tryPromise2({
|
|
197630
|
+
try: () => client.pages.update({
|
|
197631
|
+
page_id: blockedId,
|
|
197632
|
+
properties: {
|
|
197633
|
+
[propertyMapping.blockedBy]: relationProperty(newBlockers)
|
|
197634
|
+
}
|
|
197635
|
+
}),
|
|
197636
|
+
catch: (e2) => toNotionApiError(`Failed to update page: ${e2}`, e2)
|
|
197637
|
+
}).pipe(
|
|
197638
|
+
mapError2((e2) => new TaskError({ message: `Failed to add blocker: ${e2.message}`, cause: e2 }))
|
|
197639
|
+
);
|
|
197640
|
+
});
|
|
197641
|
+
const removeBlocker = (blockedId, blockerId) => gen2(function* () {
|
|
197642
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197643
|
+
const { propertyMapping } = notionConfig;
|
|
197644
|
+
const client = yield* getClient();
|
|
197645
|
+
const page = yield* tryPromise2({
|
|
197646
|
+
try: () => client.pages.retrieve({ page_id: blockedId }),
|
|
197647
|
+
catch: (e2) => toNotionApiError(`Failed to fetch page: ${e2}`, e2)
|
|
197648
|
+
}).pipe(catchAll2(handleNotFoundError(blockedId)));
|
|
197649
|
+
if (!isPageObjectResponse(page)) {
|
|
197650
|
+
return yield* fail7(new TaskNotFoundError({ taskId: blockedId }));
|
|
197651
|
+
}
|
|
197652
|
+
const currentBlockers = extractRelation(
|
|
197653
|
+
page.properties[propertyMapping.blockedBy]
|
|
197654
|
+
);
|
|
197655
|
+
const newBlockers = currentBlockers.filter((id2) => id2 !== blockerId);
|
|
197656
|
+
yield* tryPromise2({
|
|
197657
|
+
try: () => client.pages.update({
|
|
197658
|
+
page_id: blockedId,
|
|
197659
|
+
properties: {
|
|
197660
|
+
[propertyMapping.blockedBy]: relationProperty(newBlockers)
|
|
197661
|
+
}
|
|
197662
|
+
}),
|
|
197663
|
+
catch: (e2) => toNotionApiError(`Failed to update page: ${e2}`, e2)
|
|
197664
|
+
}).pipe(
|
|
197665
|
+
mapError2((e2) => new TaskError({ message: `Failed to remove blocker: ${e2.message}`, cause: e2 }))
|
|
197666
|
+
);
|
|
197667
|
+
});
|
|
197668
|
+
const addRelated = (_taskId, _relatedTaskId) => _void;
|
|
197669
|
+
const getBranchName = (id2) => gen2(function* () {
|
|
197670
|
+
const task = yield* getTask(id2);
|
|
197671
|
+
const slug = task.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 50);
|
|
197672
|
+
return `${task.identifier.toLowerCase()}-${slug}`;
|
|
197673
|
+
});
|
|
197674
|
+
const setSessionLabel = (id2, sessionId) => gen2(function* () {
|
|
197675
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197676
|
+
const { propertyMapping } = notionConfig;
|
|
197677
|
+
const client = yield* getClient();
|
|
197678
|
+
const page = yield* tryPromise2({
|
|
197679
|
+
try: () => client.pages.retrieve({ page_id: id2 }),
|
|
197680
|
+
catch: (e2) => toNotionApiError(`Failed to fetch page: ${e2}`, e2)
|
|
197681
|
+
}).pipe(catchAll2(handleNotFoundError(id2)));
|
|
197682
|
+
if (!isPageObjectResponse(page)) {
|
|
197683
|
+
return yield* fail7(new TaskNotFoundError({ taskId: id2 }));
|
|
197684
|
+
}
|
|
197685
|
+
const currentLabels = extractMultiSelect(
|
|
197686
|
+
page.properties[propertyMapping.labels]
|
|
197687
|
+
);
|
|
197688
|
+
const nonSessionLabels = currentLabels.filter(
|
|
197689
|
+
(l2) => !l2.startsWith(SESSION_LABEL_PREFIX)
|
|
197690
|
+
);
|
|
197691
|
+
const newLabels = [...nonSessionLabels, `${SESSION_LABEL_PREFIX}${sessionId}`];
|
|
197692
|
+
yield* tryPromise2({
|
|
197693
|
+
try: () => client.pages.update({
|
|
197694
|
+
page_id: id2,
|
|
197695
|
+
properties: {
|
|
197696
|
+
[propertyMapping.labels]: multiSelectProperty(newLabels)
|
|
197697
|
+
}
|
|
197698
|
+
}),
|
|
197699
|
+
catch: (e2) => toNotionApiError(`Failed to update page: ${e2}`, e2)
|
|
197700
|
+
}).pipe(
|
|
197701
|
+
mapError2((e2) => new TaskError({ message: `Failed to set session label: ${e2.message}`, cause: e2 }))
|
|
197702
|
+
);
|
|
197703
|
+
});
|
|
197704
|
+
const setTypeLabel = (id2, type3) => gen2(function* () {
|
|
197705
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197706
|
+
const { propertyMapping } = notionConfig;
|
|
197707
|
+
const client = yield* getClient();
|
|
197708
|
+
const page = yield* tryPromise2({
|
|
197709
|
+
try: () => client.pages.retrieve({ page_id: id2 }),
|
|
197710
|
+
catch: (e2) => toNotionApiError(`Failed to fetch page: ${e2}`, e2)
|
|
197711
|
+
}).pipe(catchAll2(handleNotFoundError(id2)));
|
|
197712
|
+
if (!isPageObjectResponse(page)) {
|
|
197713
|
+
return yield* fail7(new TaskNotFoundError({ taskId: id2 }));
|
|
197714
|
+
}
|
|
197715
|
+
const currentLabels = extractMultiSelect(
|
|
197716
|
+
page.properties[propertyMapping.labels]
|
|
197717
|
+
);
|
|
197718
|
+
const nonTypeLabels = currentLabels.filter(
|
|
197719
|
+
(l2) => !l2.startsWith(TYPE_LABEL_PREFIX2)
|
|
197720
|
+
);
|
|
197721
|
+
const newLabels = [...nonTypeLabels, `${TYPE_LABEL_PREFIX2}${type3}`];
|
|
197722
|
+
yield* tryPromise2({
|
|
197723
|
+
try: () => client.pages.update({
|
|
197724
|
+
page_id: id2,
|
|
197725
|
+
properties: {
|
|
197726
|
+
[propertyMapping.labels]: multiSelectProperty(newLabels)
|
|
197727
|
+
}
|
|
197728
|
+
}),
|
|
197729
|
+
catch: (e2) => toNotionApiError(`Failed to update page: ${e2}`, e2)
|
|
197730
|
+
}).pipe(
|
|
197731
|
+
mapError2((e2) => new TaskError({ message: `Failed to set type label: ${e2.message}`, cause: e2 }))
|
|
197732
|
+
);
|
|
197733
|
+
});
|
|
197734
|
+
const clearSessionLabel = (id2) => gen2(function* () {
|
|
197735
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197736
|
+
const { propertyMapping } = notionConfig;
|
|
197737
|
+
const client = yield* getClient();
|
|
197738
|
+
const page = yield* tryPromise2({
|
|
197739
|
+
try: () => client.pages.retrieve({ page_id: id2 }),
|
|
197740
|
+
catch: (e2) => toNotionApiError(`Failed to fetch page: ${e2}`, e2)
|
|
197741
|
+
}).pipe(catchAll2(handleNotFoundError(id2)));
|
|
197742
|
+
if (!isPageObjectResponse(page)) {
|
|
197743
|
+
return yield* fail7(new TaskNotFoundError({ taskId: id2 }));
|
|
197744
|
+
}
|
|
197745
|
+
const currentLabels = extractMultiSelect(
|
|
197746
|
+
page.properties[propertyMapping.labels]
|
|
197747
|
+
);
|
|
197748
|
+
const nonSessionLabels = currentLabels.filter(
|
|
197749
|
+
(l2) => !l2.startsWith(SESSION_LABEL_PREFIX)
|
|
197750
|
+
);
|
|
197751
|
+
yield* tryPromise2({
|
|
197752
|
+
try: () => client.pages.update({
|
|
197753
|
+
page_id: id2,
|
|
197754
|
+
properties: {
|
|
197755
|
+
[propertyMapping.labels]: multiSelectProperty(nonSessionLabels)
|
|
197756
|
+
}
|
|
197757
|
+
}),
|
|
197758
|
+
catch: (e2) => toNotionApiError(`Failed to update page: ${e2}`, e2)
|
|
197759
|
+
}).pipe(
|
|
197760
|
+
mapError2((e2) => new TaskError({ message: `Failed to clear session label: ${e2.message}`, cause: e2 }))
|
|
197761
|
+
);
|
|
197762
|
+
});
|
|
197763
|
+
const removeAsBlocker = (blockerId) => gen2(function* () {
|
|
197764
|
+
const notionConfig = yield* getNotionConfig(configRepo);
|
|
197765
|
+
const { propertyMapping, databaseId } = notionConfig;
|
|
197766
|
+
const client = yield* getClient();
|
|
197767
|
+
const response = yield* queryDataSource(client, databaseId, {
|
|
197768
|
+
property: propertyMapping.blockedBy,
|
|
197769
|
+
relation: { contains: blockerId }
|
|
197770
|
+
});
|
|
197771
|
+
const blockedPages = extractPages(response);
|
|
197772
|
+
const unblockedIdentifiers = [];
|
|
197773
|
+
for (const page of blockedPages) {
|
|
197774
|
+
const currentBlockers = extractRelation(page.properties[propertyMapping.blockedBy]);
|
|
197775
|
+
const newBlockers = currentBlockers.filter((id2) => id2 !== blockerId);
|
|
197776
|
+
yield* tryPromise2({
|
|
197777
|
+
try: () => client.pages.update({
|
|
197778
|
+
page_id: page.id,
|
|
197779
|
+
properties: {
|
|
197780
|
+
[propertyMapping.blockedBy]: relationProperty(newBlockers)
|
|
197781
|
+
}
|
|
197782
|
+
}),
|
|
197783
|
+
catch: (e2) => toNotionApiError(`Failed to update page: ${e2}`, e2)
|
|
197784
|
+
}).pipe(
|
|
197785
|
+
tapError2(
|
|
197786
|
+
(e2) => logWarning2(`Failed to remove blocker from page ${page.id}: ${e2.message}`)
|
|
197787
|
+
),
|
|
197788
|
+
ignore2
|
|
197789
|
+
// Continue even if one fails
|
|
197790
|
+
);
|
|
197791
|
+
const task = mapPageToTask(page, createMapConfig(notionConfig, teamId));
|
|
197792
|
+
unblockedIdentifiers.push(task.identifier);
|
|
197793
|
+
}
|
|
197794
|
+
return unblockedIdentifiers;
|
|
197795
|
+
});
|
|
197796
|
+
return {
|
|
197797
|
+
getTask,
|
|
197798
|
+
getTaskByIdentifier,
|
|
197799
|
+
createTask,
|
|
197800
|
+
updateTask,
|
|
197801
|
+
listTasks,
|
|
197802
|
+
getReadyTasks,
|
|
197803
|
+
getBlockedTasks,
|
|
197804
|
+
addBlocker,
|
|
197805
|
+
removeBlocker,
|
|
197806
|
+
addRelated,
|
|
197807
|
+
getBranchName,
|
|
197808
|
+
setSessionLabel,
|
|
197809
|
+
setTypeLabel,
|
|
197810
|
+
clearSessionLabel,
|
|
197811
|
+
removeAsBlocker
|
|
197812
|
+
};
|
|
197813
|
+
});
|
|
197814
|
+
var IssueRepositoryNotion = effect(IssueRepository, make78);
|
|
197815
|
+
|
|
195476
197816
|
// src/adapters/driven/vcs/JjParser.ts
|
|
195477
197817
|
var JJ_LOG_JSON_TEMPLATE = `
|
|
195478
197818
|
"{" ++
|
|
@@ -195763,7 +198103,7 @@ var networkRetryPolicy = intersect6(
|
|
|
195763
198103
|
recurs2(3)
|
|
195764
198104
|
);
|
|
195765
198105
|
var NETWORK_TIMEOUT = seconds(60);
|
|
195766
|
-
var
|
|
198106
|
+
var make79 = gen2(function* () {
|
|
195767
198107
|
const executor = yield* CommandExecutor2;
|
|
195768
198108
|
const escapeShellArg = (arg) => `'${arg.replace(/'/g, `'"'"'`)}'`;
|
|
195769
198109
|
const runJj = (...args2) => {
|
|
@@ -196130,7 +198470,7 @@ var make75 = gen2(function* () {
|
|
|
196130
198470
|
updateStaleWorkspace
|
|
196131
198471
|
};
|
|
196132
198472
|
});
|
|
196133
|
-
var VcsServiceLive = effect(VcsService,
|
|
198473
|
+
var VcsServiceLive = effect(VcsService, make79);
|
|
196134
198474
|
|
|
196135
198475
|
// src/adapters/driven/github/PrServiceLive.ts
|
|
196136
198476
|
var networkRetryPolicy2 = intersect6(
|
|
@@ -196182,7 +198522,7 @@ var GhIssueCommentSchema = Struct({
|
|
|
196182
198522
|
created_at: String$
|
|
196183
198523
|
});
|
|
196184
198524
|
var GhIssueCommentsArraySchema = Array$(GhIssueCommentSchema);
|
|
196185
|
-
var
|
|
198525
|
+
var make80 = gen2(function* () {
|
|
196186
198526
|
const executor = yield* CommandExecutor2;
|
|
196187
198527
|
const runGh = (...args2) => {
|
|
196188
198528
|
const cmd = make61("gh", ...args2);
|
|
@@ -196493,7 +198833,7 @@ var make76 = gen2(function* () {
|
|
|
196493
198833
|
getPrComments
|
|
196494
198834
|
};
|
|
196495
198835
|
});
|
|
196496
|
-
var PrServiceLive = effect(PrService,
|
|
198836
|
+
var PrServiceLive = effect(PrService, make80);
|
|
196497
198837
|
|
|
196498
198838
|
// ../../node_modules/.pnpm/@effect+platform@0.94.1_effect@3.19.14/node_modules/@effect/platform/dist/esm/Socket.js
|
|
196499
198839
|
var TypeId36 = /* @__PURE__ */ Symbol.for("@effect/platform/Socket");
|
|
@@ -196668,7 +199008,7 @@ var wsReconnectPolicy = intersect6(
|
|
|
196668
199008
|
recurs2(3)
|
|
196669
199009
|
);
|
|
196670
199010
|
var NETWORK_TIMEOUT3 = seconds(60);
|
|
196671
|
-
var
|
|
199011
|
+
var make81 = gen2(function* () {
|
|
196672
199012
|
const executor = yield* CommandExecutor2;
|
|
196673
199013
|
const withNetworkRetry = (effect3, operation) => effect3.pipe(
|
|
196674
199014
|
timeoutFail2({
|
|
@@ -196994,7 +199334,7 @@ var make77 = gen2(function* () {
|
|
|
196994
199334
|
connectAndStream
|
|
196995
199335
|
};
|
|
196996
199336
|
});
|
|
196997
|
-
var WebhookServiceLive = effect(WebhookService,
|
|
199337
|
+
var WebhookServiceLive = effect(WebhookService, make81);
|
|
196998
199338
|
|
|
196999
199339
|
// src/adapters/driven/opencode/OpenCodeServiceLive.ts
|
|
197000
199340
|
var DEFAULT_SERVER_URL = "http://127.0.0.1:4096";
|
|
@@ -197017,7 +199357,7 @@ var SessionStatusResponseSchema = Record({
|
|
|
197017
199357
|
key: String$,
|
|
197018
199358
|
value: SessionStatus
|
|
197019
199359
|
});
|
|
197020
|
-
var
|
|
199360
|
+
var make82 = gen2(function* () {
|
|
197021
199361
|
const serverUrl = yield* sync4(() => process.env.OPENCODE_SERVER_URL ?? DEFAULT_SERVER_URL);
|
|
197022
199362
|
const withNetworkRetry = (effect3, operation) => effect3.pipe(
|
|
197023
199363
|
timeoutFail2({
|
|
@@ -197170,7 +199510,7 @@ var make78 = gen2(function* () {
|
|
|
197170
199510
|
findActiveSession
|
|
197171
199511
|
};
|
|
197172
199512
|
});
|
|
197173
|
-
var OpenCodeServiceLive = effect(OpenCodeService,
|
|
199513
|
+
var OpenCodeServiceLive = effect(OpenCodeService, make82);
|
|
197174
199514
|
var SubscriptionEntry = class extends Class3 {
|
|
197175
199515
|
};
|
|
197176
199516
|
var isTaggedError = (e2, tag6) => typeof e2 === "object" && e2 !== null && "_tag" in e2 && e2._tag === tag6;
|
|
@@ -197745,7 +200085,7 @@ var runDaemonServer = (repo, events, webhookService, openCodeService) => gen2(fu
|
|
|
197745
200085
|
yield* interrupt4(commandProcessorFiber).pipe(ignore2);
|
|
197746
200086
|
yield* logInfo2("Daemon stopped");
|
|
197747
200087
|
});
|
|
197748
|
-
var
|
|
200088
|
+
var make83 = gen2(function* () {
|
|
197749
200089
|
const webhookService = yield* WebhookService;
|
|
197750
200090
|
const openCodeService = yield* OpenCodeService;
|
|
197751
200091
|
const isRunning2 = () => sync4(() => NFS.existsSync(DAEMON_SOCKET_PATH));
|
|
@@ -197842,7 +200182,7 @@ var make79 = gen2(function* () {
|
|
|
197842
200182
|
startDaemon
|
|
197843
200183
|
};
|
|
197844
200184
|
});
|
|
197845
|
-
var DaemonServiceLive = effect(DaemonService,
|
|
200185
|
+
var DaemonServiceLive = effect(DaemonService, make83);
|
|
197846
200186
|
|
|
197847
200187
|
// src/adapters/driven/template/TemplateServiceLive.ts
|
|
197848
200188
|
var YAML2 = __toESM(require_dist());
|
|
@@ -197907,7 +200247,7 @@ var YamlTaskTemplate = Struct({
|
|
|
197907
200247
|
|
|
197908
200248
|
// src/adapters/driven/template/TemplateServiceLive.ts
|
|
197909
200249
|
var TEMPLATES_DIR = "templates";
|
|
197910
|
-
var
|
|
200250
|
+
var make84 = gen2(function* () {
|
|
197911
200251
|
const fs = yield* FileSystem;
|
|
197912
200252
|
const path3 = yield* Path2;
|
|
197913
200253
|
const configRepo = yield* ConfigRepository;
|
|
@@ -198003,7 +200343,7 @@ var make80 = gen2(function* () {
|
|
|
198003
200343
|
hasTemplates
|
|
198004
200344
|
};
|
|
198005
200345
|
});
|
|
198006
|
-
var TemplateServiceLive = effect(TemplateService,
|
|
200346
|
+
var TemplateServiceLive = effect(TemplateService, make84);
|
|
198007
200347
|
|
|
198008
200348
|
// src/adapters/driven/prompts/PromptsLive.ts
|
|
198009
200349
|
var runPrompt = (prompt3) => tryPromise2({
|
|
@@ -198048,29 +200388,77 @@ var promptsImpl = {
|
|
|
198048
200388
|
};
|
|
198049
200389
|
var PromptsLive = succeed11(Prompts, promptsImpl);
|
|
198050
200390
|
|
|
200391
|
+
// src/infrastructure/MilestoneRepositoryStub.ts
|
|
200392
|
+
var make85 = succeed7({
|
|
200393
|
+
getMilestone: (_id) => fail7(
|
|
200394
|
+
new NotionApiError({
|
|
200395
|
+
message: "Milestones are not supported in Notion. Use Linear for milestone functionality."
|
|
200396
|
+
})
|
|
200397
|
+
),
|
|
200398
|
+
/**
|
|
200399
|
+
* Returns empty array for listing - allows UI to show "no milestones" state
|
|
200400
|
+
* rather than an error when milestones aren't supported.
|
|
200401
|
+
*/
|
|
200402
|
+
listMilestones: (_projectId) => succeed7([]),
|
|
200403
|
+
createMilestone: () => fail7(
|
|
200404
|
+
new NotionApiError({
|
|
200405
|
+
message: "Creating milestones is not supported in Notion. Use Linear for milestone functionality."
|
|
200406
|
+
})
|
|
200407
|
+
),
|
|
200408
|
+
updateMilestone: () => fail7(
|
|
200409
|
+
new NotionApiError({
|
|
200410
|
+
message: "Updating milestones is not supported in Notion. Use Linear for milestone functionality."
|
|
200411
|
+
})
|
|
200412
|
+
),
|
|
200413
|
+
deleteMilestone: () => fail7(
|
|
200414
|
+
new NotionApiError({
|
|
200415
|
+
message: "Deleting milestones is not supported in Notion. Use Linear for milestone functionality."
|
|
200416
|
+
})
|
|
200417
|
+
)
|
|
200418
|
+
});
|
|
200419
|
+
var MilestoneRepositoryStub = effect(MilestoneRepository, make85);
|
|
200420
|
+
|
|
198051
200421
|
// src/infrastructure/Layers.ts
|
|
198052
200422
|
var ConfigAndAuth = AuthServiceLive.pipe(provideMerge2(ConfigRepositoryLive));
|
|
198053
200423
|
var ConfigAuthAndLinear = LinearClientLive.pipe(provideMerge2(ConfigAndAuth));
|
|
198054
|
-
var
|
|
200424
|
+
var LinearRepositoryLayers = mergeAll5(
|
|
198055
200425
|
TeamRepositoryLive,
|
|
198056
200426
|
ProjectRepositoryLive,
|
|
198057
200427
|
IssueRepositoryLive,
|
|
198058
200428
|
MilestoneRepositoryLive
|
|
198059
200429
|
);
|
|
198060
|
-
var
|
|
198061
|
-
|
|
200430
|
+
var ConfigAuthAndNotion = NotionClientLive.pipe(provideMerge2(ConfigAndAuth));
|
|
200431
|
+
var NotionRepositoryLayers = mergeAll5(
|
|
200432
|
+
TeamRepositoryNotion,
|
|
200433
|
+
ProjectRepositoryNotion,
|
|
200434
|
+
IssueRepositoryNotion.pipe(provide3(ConfigRepositoryLive)),
|
|
200435
|
+
MilestoneRepositoryStub
|
|
200436
|
+
// Notion doesn't have milestones
|
|
200437
|
+
);
|
|
200438
|
+
var ProviderAgnosticServices = mergeAll5(
|
|
198062
200439
|
VcsServiceLive,
|
|
198063
200440
|
PrServiceLive,
|
|
198064
200441
|
WebhookServiceLive,
|
|
198065
200442
|
OpenCodeServiceLive,
|
|
198066
200443
|
TemplateServiceLive,
|
|
198067
200444
|
PromptsLive
|
|
198068
|
-
)
|
|
198069
|
-
var
|
|
198070
|
-
|
|
198071
|
-
|
|
198072
|
-
var
|
|
198073
|
-
|
|
200445
|
+
);
|
|
200446
|
+
var LinearBaseServices = mergeAll5(LinearRepositoryLayers, ProviderAgnosticServices).pipe(
|
|
200447
|
+
provideMerge2(ConfigAuthAndLinear)
|
|
200448
|
+
);
|
|
200449
|
+
var LinearAllServices = DaemonServiceLive.pipe(provideMerge2(LinearBaseServices));
|
|
200450
|
+
var AppLayer = LinearAllServices.pipe(provideMerge2(layer11));
|
|
200451
|
+
var NotionBaseServices = mergeAll5(NotionRepositoryLayers, ProviderAgnosticServices).pipe(
|
|
200452
|
+
provideMerge2(ConfigAuthAndNotion)
|
|
200453
|
+
);
|
|
200454
|
+
var NotionAllServices = DaemonServiceLive.pipe(provideMerge2(NotionBaseServices));
|
|
200455
|
+
NotionAllServices.pipe(provideMerge2(layer11));
|
|
200456
|
+
var LinearMinimalRepositories = mergeAll5(TeamRepositoryLive, ProjectRepositoryLive, PromptsLive);
|
|
200457
|
+
var LinearMinimalServices = LinearMinimalRepositories.pipe(provideMerge2(ConfigAuthAndLinear));
|
|
200458
|
+
LinearMinimalServices.pipe(provideMerge2(layer11));
|
|
200459
|
+
var NotionMinimalRepositories = mergeAll5(TeamRepositoryNotion, ProjectRepositoryNotion, PromptsLive);
|
|
200460
|
+
var NotionMinimalServices = NotionMinimalRepositories.pipe(provideMerge2(ConfigAuthAndNotion));
|
|
200461
|
+
NotionMinimalServices.pipe(provideMerge2(layer11));
|
|
198074
200462
|
|
|
198075
200463
|
// src/bin.ts
|
|
198076
200464
|
run9(process.argv).pipe(
|