@forge/util

2.0.1-experimental-78908582.0.1-experimental-04cc2b9
packages/ari/google.google-drive-lite/index.js
packages/ari/google.google-drive-lite/index.jsDeleted
−335
Index: package/packages/ari/google.google-drive-lite/index.js
===================================================================
--- package/packages/ari/google.google-drive-lite/index.js
+++ package/packages/ari/google.google-drive-lite/index.js
@@ -1,335 +0,0 @@
-"use strict";
-var __defProp = Object.defineProperty;
-var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
-var __getOwnPropNames = Object.getOwnPropertyNames;
-var __hasOwnProp = Object.prototype.hasOwnProperty;
-var __export = (target, all) => {
-  for (var name in all)
-    __defProp(target, name, { get: all[name], enumerable: !0 });
-}, __copyProps = (to, from, except, desc) => {
-  if (from && typeof from == "object" || typeof from == "function")
-    for (let key of __getOwnPropNames(from))
-      !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
-  return to;
-};
-var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
-
-// src/google.google-drive-lite/index.ts
-var google_exports = {};
-__export(google_exports, {
-  GoogleGoogleDriveLiteDocumentAri: () => GoogleGoogleDriveLiteDocumentAri
-});
-module.exports = __toCommonJS(google_exports);
-
-// src/errors.ts
-var ValidationError = class extends Error {
-};
-
-// src/core/rules/cloud-id.ts
-function validateCloudId(cloudId, format = new RegExp("^[a-zA-Z0-9_\\-.]{0,255}$")) {
-  if (!cloudId.match(format))
-    throw new ValidationError(`Invalid cloud ID, expected ID of format ${format}.`);
-}
-
-// src/core/rules/platform-qualifier.ts
-function validatePlatformQualifier(qualifier) {
-  if (qualifier !== "cloud" && qualifier !== "third-party")
-    throw new ValidationError(`Identifier must have a qualifier of 'cloud' or 'third-party'. Received: ${qualifier}`);
-}
-
-// src/core/rules/qualifier.ts
-function validateAtiQualifier(qualifier) {
-  if (qualifier !== "ati")
-    throw new ValidationError(`ATI must have a qualifier of 'ati'. Received: ${qualifier}`);
-}
-function validateAriQualifier(qualifier) {
-  if (qualifier !== "ari")
-    throw new ValidationError(`ARI must have a qualifier of 'ari'. Received: ${qualifier}`);
-}
-
-// src/core/rules/resource-id.ts
-function validateResourceId(id, format = new RegExp("[!a-zA-Z0-9\\-_.~@:;{}=]+(/[!a-zA-Z0-9\\-_.~@:;{}=]+)*" /* ANY_RESOURCE_ID */), key = "resourceId") {
-  let formatWithCarets = new RegExp(`^${format.source}$`);
-  if (!id.match(formatWithCarets))
-    throw new ValidationError(`Invalid ${key} - ${id}, expected ID of format ${formatWithCarets}.`);
-}
-
-// src/core/rules/resource-id-segments.ts
-function validateResourceIdSegments(resourceIdSegmentValues, resourceIdSegmentFormats) {
-  Object.entries(resourceIdSegmentValues).forEach(([resourceIdKey, resourceIdValue]) => {
-    validateResourceId(resourceIdValue, resourceIdSegmentFormats == null ? void 0 : resourceIdSegmentFormats[resourceIdKey], resourceIdKey);
-  });
-}
-
-// src/core/rules/resource-owner.ts
-function validateResourceOwner(owner, expectedResourceOwner) {
-  if (expectedResourceOwner && owner !== expectedResourceOwner)
-    throw new ValidationError(`Invalid resource owner - ${owner}, expected ${expectedResourceOwner}.`);
-}
-
-// src/core/rules/resource-type.ts
-function validateResourceType(type, expectedResourceType) {
-  if (expectedResourceType && type !== expectedResourceType)
-    throw new ValidationError(`Invalid resource type - ${type}, expected ${expectedResourceType}.`);
-}
-
-// src/core/parser/base.ts
-var NUMBER_OF_BASE_SEGMENTS = 5, SEGMENT_SEPARATOR = ":", BaseParser = class {
-  static getIdentifierSegments(inputStr, numberOfSegmentsRequired) {
-    let allSegments = inputStr.split(SEGMENT_SEPARATOR);
-    if (allSegments.length < numberOfSegmentsRequired)
-      throw new ValidationError(`Input string must have ${numberOfSegmentsRequired} segments.`);
-    if (allSegments.length > numberOfSegmentsRequired) {
-      let segments = allSegments.slice(0, NUMBER_OF_BASE_SEGMENTS - 1), segmentsForResourceId = allSegments.slice(NUMBER_OF_BASE_SEGMENTS - 1, allSegments.length);
-      return [...segments, segmentsForResourceId.join(SEGMENT_SEPARATOR)];
-    }
-    return allSegments;
-  }
-};
-
-// src/core/parser/ari.ts
-var NUMBER_OF_ARI_SEGMENTS = 5, AriParser = class extends BaseParser {
-  static fromString(maybeAri, ariProperties) {
-    let segments = this.getIdentifierSegments(maybeAri, NUMBER_OF_ARI_SEGMENTS), [qualifier, platformQualifier, resourceOwner, cloudId, resourceTypeAndId] = segments, [resourceType, ...resourceIdSegments] = resourceTypeAndId.split("/"), maybeAriDerivedProperties = {
-      qualifier,
-      platformQualifier,
-      cloudId,
-      resourceOwner,
-      resourceType,
-      resourceId: resourceIdSegments.join("/"),
-      resourceIdSegmentValues: ariProperties != null && ariProperties.resourceIdSlug ? this.ariSegmentValuesFromSlug(
-        ariProperties.resourceIdSlug,
-        resourceIdSegments.join("/"),
-        Object.keys(ariProperties.resourceIdSegmentFormats)
-      ) : {}
-    };
-    return this.fromOpts(maybeAriDerivedProperties, ariProperties);
-  }
-  static fromOpts(maybeAriOpts, ariProperties) {
-    let {
-      qualifier = "ari",
-      platformQualifier = "cloud",
-      resourceOwner,
-      cloudId,
-      resourceId,
-      resourceIdSegmentValues,
-      resourceType
-    } = maybeAriOpts;
-    return validateAriQualifier(qualifier), validatePlatformQualifier(platformQualifier), validateCloudId(maybeAriOpts.cloudId || "", ariProperties == null ? void 0 : ariProperties.cloudId), validateResourceOwner(resourceOwner, ariProperties == null ? void 0 : ariProperties.resourceOwner), validateResourceType(resourceType, ariProperties == null ? void 0 : ariProperties.resourceType), validateResourceIdSegments(resourceIdSegmentValues, ariProperties == null ? void 0 : ariProperties.resourceIdSegmentFormats), {
-      qualifier,
-      resourceOwner,
-      resourceType,
-      platformQualifier,
-      cloudId,
-      resourceId,
-      resourceIdSegmentValues
-    };
-  }
-  static ariSegmentValuesFromSlug(slug, incomingSegments, expectedKeys) {
-    let regexpResult = new RegExp("^" + slug.replace(/\{(.*?)\}/g, "(?<$1>.*?)") + "$").exec(incomingSegments);
-    if (!regexpResult)
-      throw new ValidationError(`Segment '${incomingSegments}' don't match expected slug: ${slug}`);
-    return expectedKeys.forEach((expectedKey) => {
-      var _a;
-      if (!((_a = regexpResult.groups) != null && _a[expectedKey]))
-        throw new ValidationError(`No value supplied for '${expectedKey}' based on slug ${slug}`);
-    }), regexpResult.groups || {};
-  }
-};
-
-// src/core/parser/ati.ts
-var NUMBER_OF_ATI_SEGMENTS = 4, AtiParser = class extends BaseParser {
-  static fromString(inputStr, atiOpts) {
-    let segments = this.getIdentifierSegments(inputStr, NUMBER_OF_ATI_SEGMENTS), [qualifier = "ati", platformQualifier = "cloud", resourceOwner, resourceType] = segments;
-    return validateAtiQualifier(qualifier), validatePlatformQualifier(platformQualifier), validateResourceOwner(resourceOwner, atiOpts == null ? void 0 : atiOpts.resourceOwner), validateResourceType(resourceType, atiOpts == null ? void 0 : atiOpts.resourceType), { platformQualifier, resourceOwner, resourceType };
-  }
-  static fromOpts(maybeAtiOpts, atiOpts) {
-    let { qualifier, platformQualifier, resourceOwner, resourceType } = maybeAtiOpts;
-    return validateAtiQualifier(qualifier), validatePlatformQualifier(platformQualifier), validateResourceOwner(resourceOwner, atiOpts == null ? void 0 : atiOpts.resourceOwner), validateResourceType(resourceType, atiOpts == null ? void 0 : atiOpts.resourceType), {
-      platformQualifier,
-      resourceOwner,
-      resourceType
-    };
-  }
-};
-
-// src/ati.ts
-var Ati = class _Ati {
-  constructor(platformQualifier, resourceOwner, resourceType) {
-    this._platformQualifier = platformQualifier, this._resourceOwner = resourceOwner, this._resourceType = resourceType;
-  }
-  get platformQualifier() {
-    return this._platformQualifier;
-  }
-  get resourceOwner() {
-    return this._resourceOwner;
-  }
-  get resourceType() {
-    return this._resourceType;
-  }
-  static create(opts) {
-    return new _Ati(opts.platformQualifier || "cloud", opts.resourceOwner, opts.resourceType);
-  }
-  static parse(maybeAti, atiOpts) {
-    let opts = AtiParser.fromString(maybeAti, atiOpts);
-    return new _Ati(opts.platformQualifier, opts.resourceOwner, opts.resourceType);
-  }
-  toString() {
-    return `ati:${this.platformQualifier}:${this.resourceOwner}:${this.resourceType}`;
-  }
-  toJSON() {
-    return this.toString();
-  }
-  toOpts() {
-    return {
-      platformQualifier: this._platformQualifier,
-      resourceOwner: this._resourceOwner,
-      resourceType: this._resourceType
-    };
-  }
-};
-
-// src/core/ari.ts
-var Ari = class {
-  constructor(opts) {
-    this._ati = Ati.create({
-      platformQualifier: opts.platformQualifier || "cloud",
-      resourceOwner: opts.resourceOwner,
-      resourceType: opts.resourceType
-    }), this._cloudId = opts.cloudId !== "" ? opts.cloudId : void 0, this._resourceId = opts.resourceId;
-  }
-  get platformQualifier() {
-    return this._ati.platformQualifier;
-  }
-  get cloudId() {
-    return this._cloudId;
-  }
-  get resourceOwner() {
-    return this._ati.resourceOwner;
-  }
-  get resourceType() {
-    return this._ati.resourceType;
-  }
-  get resourceId() {
-    return this._resourceId;
-  }
-  get ati() {
-    return this._ati;
-  }
-  equals(other) {
-    return this.toString() === other.toString();
-  }
-  toString() {
-    return `ari:${this.platformQualifier}:${this.resourceOwner}:${this.cloudId || ""}:${this.resourceType}/${this.resourceId}`;
-  }
-  toJSON() {
-    return this.toString();
-  }
-  toOpts() {
-    return {
-      platformQualifier: this.platformQualifier,
-      resourceOwner: this.resourceOwner,
-      cloudId: this.cloudId,
-      resourceType: this.resourceType,
-      resourceId: this.resourceId
-    };
-  }
-};
-
-// src/any-ari.ts
-var AnyAri = class _AnyAri extends Ari {
-  constructor(opts) {
-    super(opts);
-  }
-  static create(ariOpts, ariStaticOpts) {
-    let ariOptsWithDefaults = { ...ariOpts, resourceIdSegmentValues: {} }, validatedOpts = AriParser.fromOpts(ariOptsWithDefaults, ariStaticOpts);
-    return new _AnyAri(validatedOpts);
-  }
-  static parse(maybeAri, ariStaticOpts) {
-    let validatedOpts = AriParser.fromString(maybeAri, ariStaticOpts);
-    return new _AnyAri(validatedOpts);
-  }
-  static check(maybeAri) {
-    try {
-      return _AnyAri.parse(maybeAri.toString()), !0;
-    } catch (err) {
-      return !1;
-    }
-  }
-  asAnyAri() {
-    return this;
-  }
-};
-
-// src/core/registered-ari.ts
-var RegisteredAri = class extends Ari {
-  static check(maybeAri) {
-    try {
-      return this.parse(maybeAri.toString()), !0;
-    } catch (err) {
-      return !1;
-    }
-  }
-  asAnyAri() {
-    return AnyAri.parse(this.toString());
-  }
-};
-
-// src/google.google-drive-lite/document/types.ts
-var GoogleGoogleDriveLiteDocumentAriResourceOwner = "google.google-drive-lite", GoogleGoogleDriveLiteDocumentAriResourceType = "document";
-
-// src/google.google-drive-lite/document/manifest.ts
-var googleGoogleDriveLiteDocumentAriStaticOpts = {
-  qualifier: "ari",
-  platformQualifier: "third-party",
-  cloudId: new RegExp("^$"),
-  resourceOwner: GoogleGoogleDriveLiteDocumentAriResourceOwner,
-  resourceType: GoogleGoogleDriveLiteDocumentAriResourceType,
-  resourceIdSlug: "{googleDriveDocumentIdType}/{docId}",
-  resourceIdSegmentFormats: {
-    googleDriveDocumentIdType: /(documentId|spreadsheetId|presentationId|formId|folderId|imageId|audioId|videoId|pdfId|shortcutId|codeId|archiveId|web-pageId|pageId|blogpostId|otherId)/,
-    docId: /[a-zA-Z0-9_-]+/
-  }
-};
-
-// src/google.google-drive-lite/document/index.ts
-var GoogleGoogleDriveLiteDocumentAri = class _GoogleGoogleDriveLiteDocumentAri extends RegisteredAri {
-  constructor(opts) {
-    super(opts), this._googleDriveDocumentIdType = opts.resourceIdSegmentValues.googleDriveDocumentIdType, this._docId = opts.resourceIdSegmentValues.docId;
-  }
-  get googleDriveDocumentIdType() {
-    return this._googleDriveDocumentIdType;
-  }
-  get docId() {
-    return this._docId;
-  }
-  static create(opts) {
-    let derivedOpts = {
-      qualifier: googleGoogleDriveLiteDocumentAriStaticOpts.qualifier,
-      platformQualifier: googleGoogleDriveLiteDocumentAriStaticOpts.platformQualifier,
-      cloudId: void 0,
-      resourceOwner: googleGoogleDriveLiteDocumentAriStaticOpts.resourceOwner,
-      resourceType: googleGoogleDriveLiteDocumentAriStaticOpts.resourceType,
-      resourceId: `${opts.googleDriveDocumentIdType}/${opts.docId}`,
-      resourceIdSegmentValues: {
-        googleDriveDocumentIdType: opts.googleDriveDocumentIdType,
-        docId: opts.docId
-      }
-    }, ariOpts = AriParser.fromOpts(derivedOpts, googleGoogleDriveLiteDocumentAriStaticOpts);
-    return new _GoogleGoogleDriveLiteDocumentAri(ariOpts);
-  }
-  static parse(maybeAri) {
-    let opts = AriParser.fromString(maybeAri, googleGoogleDriveLiteDocumentAriStaticOpts);
-    return new _GoogleGoogleDriveLiteDocumentAri(opts);
-  }
-  getVariables() {
-    return {
-      googleDriveDocumentIdType: this.googleDriveDocumentIdType,
-      docId: this.docId
-    };
-  }
-};
-// Annotate the CommonJS export names for ESM import in node:
-0 && (module.exports = {
-  GoogleGoogleDriveLiteDocumentAri
-});