How to use the slugid.decode function in slugid

To help you get started, we’ve selected a few slugid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taskcluster / taskcluster / services / auth / auth / data.js View on Github external
return JSON.stringify(value);
  }
  // Serialize data object
  if (type == 'date') {
    assert(
      value instanceof Date,
      "Value '" + value + "' must be an instance of Date object for " +
      "property " + entry.property
    );
    return value;
  }
  // Serialize slug to uuid which azure tables can encode efficiently
  if (type == 'slugid') {
    assert(value, "Slugs can't be empty string!!!");
    assert(value.length == 22, "Slugs should always be 22 chars long");
    return slugid.decode(value);
  }
  throw new Error("Can't serialize unknown type: '" + type + "' for " +
                  "property: '" + entry.property + "'!");
};
github taskcluster / mozilla-taskcluster / src / jobs / retrigger.js View on Github external
// Chunks are often numbers type cast here so we don't need to enforce
  // this everywhere...
  if (typeof treeherder.symbol === 'number') {
    treeherder.symbol = String(treeherder.symbol);
  }

  // Validation is useful primarily for use with kue viewer as you can easily
  // see what failed during the validation.
  let validate = Joi.validate(treeherder, SCHEMA);
  if (validate.error) {
    throw new Error(validate.error.annotate());
  }

  let config = validate.value;
  let job = {
    job_guid: `${slugid.decode(taskId)}/${run.runId}`,
    build_system_type: 'taskcluster',
    build_platform: config.build,
    machine_platform: config.machine,
    machine: config.machineId,
    // Maximum job name length is 100 chars...
    name: task.metadata.name.slice(0, 99),
    reason: 'scheduled',  // use reasonCreated or reasonResolved
    job_symbol: config.symbol,
    submit_timestamp: timestamp(task.created),
    start_timestamp: (run.started ? timestamp(run.started) : undefined),
    end_timestamp: (run.resolved ? timestamp(run.resolved) : undefined),
    who: task.metadata.owner,
    option_collection: config.collection
  };

  // Optional configuration details if these keys are present it has an effect
github taskcluster / mozilla-taskcluster / src / treeherder / handler.js View on Github external
await project.postJobs(status.runs.map((run) => {
      var result = {
        project:            project.project,
        revision_hash:      revisionHash,
        job: {
          job_guid:         slugid.decode(status.taskId) + '/' + run.runId,
          build_platform: {
              platform:     status.workerType,
              os_name:      '-',
              architecture: '-'
          },
          machine_platform: {
              platform:     status.workerType,
              os_name:      '-',
              architecture: '-'
          },
          name:             task.metadata.name,
          reason:           'scheduled',  // use reasonCreated or reasonResolved
          job_symbol:       task.extra.treeherder.symbol,
          group_name:       task.extra.treeherder.groupName,
          group_symbol:     task.extra.treeherder.groupSymbol,
          product_name:     task.extra.treeherder.productName,
github taskcluster / mozilla-taskcluster / src / treeherder / job_handler.js View on Github external
// Chunks are often numbers type cast here so we don't need to enforce
  // this everywhere...
  if (typeof treeherder.symbol === 'number') {
    treeherder.symbol = String(treeherder.symbol);
  }

  // Validation is useful primarily for use with kue viewer as you can easily
  // see what failed during the validation.
  let validate = Joi.validate(treeherder, SCHEMA);
  if (validate.error) {
    throw new Error(validate.error.annotate());
  }

  let config = validate.value;
  let job = {
    job_guid: `${slugid.decode(taskId)}/${run.runId}`,
    build_system_type: 'taskcluster',
    build_platform: config.build,
    machine_platform: config.machine,
    machine: config.machineId,
    // Maximum job name length is 100 chars...
    name: task.metadata.name.slice(0, 99),
    reason: 'scheduled',  // use reasonCreated or reasonResolved
    job_symbol: config.symbol,
    submit_timestamp: timestamp(task.created),
    start_timestamp: (run.started ? timestamp(run.started) : undefined),
    end_timestamp: (run.resolved ? timestamp(run.resolved) : undefined),
    who: task.metadata.owner,
    option_collection: config.collection
  };

  // Optional configuration details if these keys are present it has an effect
github taskcluster / taskcluster / services / queue / queue / taskstore.js View on Github external
function incomingTask(input) {
  var record = TASK_FIELDS.reduce(function(record, key) {
    record[key] = input[key];
    return record;
  }, {});

  record.taskId = slugid.decode(record.taskId);
  return record;
}
github taskcluster / taskcluster / libraries / app / entity.js View on Github external
serialize:    function(d) {
    assert(d,                   "Slugs must be a string");
    assert.equal(d.length, 22,  "Slugs should always be 22 chars long");
    return slugid.decode(d);
  },
  deserialize:  function(r) {

slugid

URL-safe base64 UUID encoder for generating 22 character slugs

MIT
Latest version published 5 months ago

Package Health Score

82 / 100
Full package analysis