创建 action
@param {String} type action 类型
@param {*} payload 数据载体
@param {*} meta 元信息
@param {Object} data 其它数据
487009
function actionCreator(type, payload, meta) {
  var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};

  var action = _objectSpread({
    type: type,
    payload: payload
  }, data);

  if (payload instanceof Error) {
    action.error = true;
  }

  if (meta) {
    action.meta = meta;
  }

  return action;
}
1369941
function onMetadata (metadata) {
  metadata = icy.parse(metadata);
  console.error('METADATA EVENT:');
  console.error(metadata);
}
1263484
function(action) {
			var list = this._trackedtypes[action.type];
			if (list) {
				list.forEach(function(checks) {
					var handler = checks[0];
					var matches = checks[1] === action.global;
					var hacking = handler === this.spirit && this.$handleownaction;
					if (matches && (handler !== action.target || hacking)) {
						handler.onaction(action);
					}
				}, this);
			}
		}
574633
function doDispatch(action, _payload, _options) {
      let bodyPayload = {
        type: action,
        payload: {}
      };
      if (typeof _payload === 'object' && _payload) {
        bodyPayload.payload = _payload;
      }
      let options = (typeof _options === 'object' && _options ? _options : {});
      try {
        bodyPayload = JSON.stringify(bodyPayload);
      } catch (e) {
        return Promise.reject(thorin.error('FETCH.DATA', 'Failed to stringify fetch payload.', e, 400));
      }
      let fetchOptions = thorin.util.extend({
        body: bodyPayload,
        headers: {
          connection: 'keep-alive'
        }
      }, opt, options);
      let statusCode;
      return nodeFetch(url, fetchOptions)
        .then((res) => {
          statusCode = res.status;
          return res.json();
        }).then((resultData) => {
          if (statusCode >= 200 && statusCode <= 299) {
            if (resultData.type) {
              delete resultData.type;
            }
            return Promise.resolve(resultData);
          }
          const errData = resultData.error || {},
            msg = errData.message || 'Failed to execute fetch',
            status = errData.status || 400,
            code = (errData.code || 'FETCH.ERROR');
          let err = thorin.error(code, msg, status);
          err.ns = 'FETCH';
          if (!err.data) err.data = {};
          err.data.action = action;
          throw err;
        }).catch((e) => {
          if (e && e.ns === 'FETCH') return Promise.reject(e);
          let msg = '',
            status = 400,
            code = 'FETCH.';
          if (e) {
            if (e instanceof SyntaxError) {
              code += 'RESPONSE';
              msg = 'Request data could not be processed.';
            } else {
              switch (e.type) {
                case 'request-timeout':
                  code += 'TIMEOUT';
                  msg = 'Request timed out';
                  break;
                default:
                  code += 'ERROR';
                  msg = 'Could not contact the server';
                  status = statusCode || 400;
              }
            }
          }
          let tErr = thorin.error(code, msg, status, e);
          if (!tErr.data) tErr.data = {};
          tErr.data.action = action;
          return Promise.reject(tErr);
        });
    }
993192
def action(self, item, action_type, body={}):
        
        uri = "/%s/%s/action" % (self.uri_base, utils.get_id(item))
        action_body = {action_type: body}
        return self.api.method_post(uri, body=action_body)
772810
function(type, data) {
            var handlers,
                i,
                len,
                event = buildEventObject(type, data);

            // if there are handlers for the event, call them in order
            handlers = this._handlers[event.type];
            if (handlers instanceof Array) {
                // @NOTE: do a concat() here to create a copy of the handlers array,
                // so that if another handler is removed of the same type, it doesn't
                // interfere with the handlers array
                handlers = handlers.concat();
                for (i = 0, len = handlers.length; i < len; i++) {
                    if (handlers[i]) {
                        handlers[i].call(this, event);
                    }
                }
            }

            // call handlers for `all` event type
            handlers = this._handlers.all;
            if (handlers instanceof Array) {
                // @NOTE: do a concat() here to create a copy of the handlers array,
                // so that if another handler is removed of the same type, it doesn't
                // interfere with the handlers array
                handlers = handlers.concat();
                for (i = 0, len = handlers.length; i < len; i++) {
                    if (handlers[i]) {
                        handlers[i].call(this, event);
                    }
                }
            }

            return event;
        }
701519
function createWatchEvent(type, record, event) {
    const payload = Object.assign({ type, key: record.id, modelName: record.modelName, pluralName: record.pluralName, modelConstructor: record.modelConstructor, dynamicPathProperties: record.dynamicPathComponents, compositeKey: record.compositeKey, dbPath: record.dbPath, localPath: record.localPath || "", localPostfix: record.META.localPostfix }, event);
    return payload;
}
972741
function (data) {
        var msg = messages.unwrap(data);
        if (!msg) {
            logger.error("routeMessage got a NULL coap message ", { coreID: this.getHexCoreID() });
            return;
        }

        this._lastMessageTime = new Date();

        //should be adequate
        var msgCode = msg.getCode();
        if ((msgCode > Message.Code.EMPTY) && (msgCode <= Message.Code.DELETE)) {
            //probably a request
            msg._type = messages.getRequestType(msg);
        }

        if (!msg._type) {
            msg._type = this.getResponseType(msg.getTokenString());
        }

        //console.log("core got message of type " + msg._type + " with token " + msg.getTokenString() + " " + messages.getRequestType(msg));

        if (msg.isAcknowledgement()) {
            if (!msg._type) {
                //no type, can't route it.
                msg._type = 'PingAck';
            }
            this.emit(('msg_' + msg._type).toLowerCase(), msg);
            return;
        }


        var nextPeerCounter = ++this.recvCounter;
        if (nextPeerCounter > 65535) {
            //TODO: clean me up! (I need settings, and maybe belong elsewhere)
            this.recvCounter = nextPeerCounter = 0;
        }

        if (msg.isEmpty() && msg.isConfirmable()) {
            this._lastCorePing = new Date();
            //var delta = (this._lastCorePing - this._connStartTime) / 1000.0;
            //logger.log("core ping @ ", delta, " seconds ", { coreID: this.getHexCoreID() });
            this.sendReply("PingAck", msg.getId());
            return;
        }

        if (!msg || (msg.getId() != nextPeerCounter)) {
            logger.log("got counter ", msg.getId(), " expecting ", nextPeerCounter, { coreID: this.getHexCoreID() });

            if (msg._type == "Ignored") {
                //don't ignore an ignore...
                this.disconnect("Got an Ignore");
                return;
            }

            //this.sendMessage("Ignored", null, {}, null, null);
            this.disconnect("Bad Counter");
            return;
        }

        this.emit(('msg_' + msg._type).toLowerCase(), msg);
    }
1247339
async def flexible_api_handler(service, action_type, payload, props, **kwds):
    
    # if the action represents a new service
    if action_type == intialize_service_action():
        # the treat the payload like json if its a string
        model = json.loads(payload) if isinstance(payload, str) else payload

        # the list of known models
        models = service._external_service_data['models']
        # the list of known connections
        connections = service._external_service_data['connections']
        # the list of known mutations
        mutations = service._external_service_data['mutations']

        # if the model is a connection
        if 'connection' in model:
            # if we haven't seen the connection before
            if not [conn for conn in connections if conn['name'] == model['name']]:
                # add it to the list
                connections.append(model)

        # or if there are registered fields
        elif 'fields' in model and not [mod for mod in models if mod['name'] == model['name']]:
            # add it to the model list
            models.append(model)

        # the service could provide mutations as well as affect the topology
        if 'mutations' in model:
            # go over each mutation announce
            for mutation in model['mutations']:
                # if there isn't a mutation by the same name in the local cache
                if not [mut for mut in mutations if mut['name'] == mutation['name']]:
                    # add it to the local cache
                    mutations.append(mutation)

        # if there are models
        if models:
            # create a new schema corresponding to the models and connections
            service.schema = generate_api_schema(
                models=models,
                connections=connections,
                mutations=mutations,
            )
332077
function putMeta(uri, data) {
  const id = replaceVersion(uri.replace('/meta', ''));

  return db.putMeta(id, data)
    .then(pubToBus(id));
}
393739
function attachActionsToTransport(transportObj, _actions) {
    let actionList = (typeof _actions === 'object' ? _actions : this[actions]);
    Object.keys(actionList).forEach((name) => {
      let actionObj = this[actions][name] && this[actions][name].action;
      if (actionObj) {
        let opt = this[actions][name].opt;
        if (opt.transport && opt.transport !== transportObj.name) return;
      }
      let k = transportObj._id + ':' + actionObj._id;
      if (typeof this[tracking][k] !== 'undefined') return;
      transportObj.routeAction(actionObj);
      this[tracking][k] = true;
    });
    for (let i = 0; i < unsavedActions.length; i++) {
      let item = unsavedActions[i];
      if (item.opt.transport && item.opt.transport !== transportObj.name) continue;
      let k = transportObj._id + ':' + item.action._id;
      if (typeof this[tracking][k] !== 'undefined') continue;
      transportObj.routeAction(item.action);
      this[tracking][k] = true;
    }
  }
588457
function(data, payload) {
        var type = data.length > 0 ? data[0].type : null;
        var serializer = this;
        data.forEach(function(item) {
          if(item.relationships) {
            serializer.extractRelationships(item.relationships, item);
          }
        });

        payload[type] = data;
      }
1195501
def _api_request(self, action, data, request_type, headers=None):
        
        if 'file' in data:
            file_data = {'file': open(data['file'], 'rb')}
        else:
            file_data = None

        return self._http_request(action, self._prepare_json_payload(data), request_type, file_data, headers)
1036185
public ApiResponse<MessageIDEnvelope> sendActionsWithHttpInfo(Actions data) throws ApiException {
        com.squareup.okhttp.Call call = sendActionsValidateBeforeCall(data, null, null);
        Type localVarReturnType = new TypeToken<MessageIDEnvelope>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
885740
function createFrame (type, payload) {
  var err = validateArgs(type, payload);
  if (err) { throw err; }

  var payloadBuffer = Buffer.isBuffer(payload) ? payload : new Buffer(payload);
  var headerBuffer  = createHeader(type, payload.length);

  return Buffer.concat([headerBuffer, payloadBuffer]);
}
661712
function EventData(eventId, type, isJson, data, metadata) {
  if (!isValidId(eventId)) throw new TypeError("eventId must be a string containing a UUID.");
  if (typeof type !== 'string' || type === '') throw new  TypeError("type must be a non-empty string.");
  if (isJson && typeof isJson !== 'boolean') throw new TypeError("isJson must be a boolean.");
  if (data && !Buffer.isBuffer(data)) throw new TypeError("data must be a Buffer.");
  if (metadata && !Buffer.isBuffer(metadata)) throw new TypeError("metadata must be a Buffer.");

  this.eventId = eventId;
  this.type = type;
  this.isJson = isJson || false;
  this.data = data || new Buffer(0);
  this.metadata = metadata || new Buffer(0);
  Object.freeze(this);
}
968332
function pushListener(event) {
    var jsonString = event.data && event.data.text() ? event.data.text() : null;

    if (!jsonString) {
      console.log('Leanplum: Push received without payload, skipping display.');
      return;
    }

    // noinspection JSCheckFunctionSignatures
    var options = JSON.parse(jsonString);

    /** @namespace options.title The title of the push notification. **/
    /** @namespace options.tag The id of the push notification **/
    if (!options || !options.title || !options.tag) {
      console.log('Leanplum: No options, title or tag/id received, skipping ' + 'display.');
      return;
    }

    // Extract open action url. We only support open url action for now.
    /** @namespace options.data.openAction The openAction of the push notification. **/
    if (options.data && options.data.openAction && options.data.openAction.hasOwnProperty(ACTION_NAME_KEY) && options.data.openAction[ACTION_NAME_KEY] === OPEN_URL_ACTION && options.data.openAction.hasOwnProperty(ARG_URL)) {
      openActions[options.tag] = options.data.openAction[ARG_URL];
    }

    // Extract title and delete from options.
    var title = options.title;
    Reflect.deleteProperty(options, 'title');
    /** @namespace self.registration **/
    /** @namespace self.registration.showNotification **/
    event.waitUntil(self.registration.showNotification(title, options));
  }